hi,
ok, right. CU 397 uses the .net assembly Microsoft.Dynamics.Nav.Integration.Office. there is no possibility to set/change the sender address for creating a mail message with the classes delivered by that assembly.
the Microsoft.Dynamics.Nav.Integration.Office.dll references (internally) the assembly Microsoft.Office.Interop.Outlook.
using that assembly you can create a mail message and set the sender mail address.
the variables:
--------------------------------
olApp DotNet Microsoft.Office.Interop.Outlook.ApplicationClass.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
olMailItem DotNet Microsoft.Office.Interop.Outlook.MailItem.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
olItemType DotNet Microsoft.Office.Interop.Outlook.OlItemType.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
olAccountList DotNet Microsoft.Office.Interop.Outlook.Accounts.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
olAccount DotNet Microsoft.Office.Interop.Outlook.Account.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
olAttachmentType DotNet Microsoft.Office.Interop.Outlook.OlAttachmentType.'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
fileName Text
senderMailAddress Text
idx Integer
the code:
--------------------------
// here select the sender Address from table company information,
// fields Email, "Email 2".
senderMailAddress := 'sender@test.com';
olApp := olApp.ApplicationClass;
olMailItem := olApp.CreateItem(olItemType.olMailItem);
// find the selected outlook profile and set it as sender mailAddress
olAccountList := olApp.Session.Accounts;
idx := 1;
REPEAT
olAccount := olAccountList.Item(idx);
IF LOWERCASE(olAccount.SmtpAddress) = LOWERCASE(senderMailAddress) THEN
olMailItem.SendUsingAccount := olAccount;
idx += 1;
UNTIL idx > olAccountList.Count;
olMailItem.Subject := 'subject text';
olMailItem."To" := 'receiver@test.com';
olMailItem.Body := 'This is the message.';
fileName := 'c:\temp\test.docx';
olMailItem.Attachments.Add(fileName,olAttachmentType.olByValue,1,fileName);
olMailItem.Display(TRUE);