Hi
I have created a beautiful email with HTML formatting by use of codeunit 397 - the user should be able to read/modify the email before sending. My problem is that the signature is missing...From my point of view, it should be a simple task to call some kind of .Net add-in that would choose the standard signature (the user can have more than one) and add it to the end of the mail (that is: do the same thing as Outlook does when creating a new email manually). 'Microsoft.Office.Interop.Outlook' assembly has a lot of 'type's but I'm sure which one might do the job (or one of them at all?). I have googled for a solution but without any luck
Answers
this is not that easy to achieve.
The question was asked in c# forums as well and got some Solutions:
stackoverflow.com/questions/6442747/add-the-default-outlook-signature-in-the-email-generated
I used the second solution of this question where they append the Body after displaying the mail:
I have tried it but the body never contains html statements, only the text..
Therefor you'll not be able to get the signature easily by setting a parameter in codeunit 397.
I think you'll have to create an own functionality that's using default .net Outlook functions or build you own class.
I've successfully tested it with:
Use the following DotNet Variables:
lOutlookApp DotNet Microsoft.Office.Interop.Outlook.ApplicationClass.'Microsoft.Office.Interop.Outlook,
lOutlookItemType DotNet Microsoft.Office.Interop.Outlook.OlItemType.'Microsoft.Office.Interop.Outlook,
lMailItem DotNet Microsoft.Office.Interop.Outlook.MailItem.'Microsoft.Office.Interop.Outlook
IT WORKS!!!!!! Just remember to put 'RunOnClient' = YES on the 3 DotNet variables. My samplecode looks like this (I don't know how to insert a screen-shot):
lOutlookApp := lOutlookApp.ApplicationClass;
lMailItem := lOutlookApp.CreateItem(lOutlookItemType.olMailItem);
lMailItem."To" := 'some@e-mail.com';
lMailItem.CC := '';
lMailItem.Subject := 'Subject';
lMailItem.Display(lMailItem);
lMailItem.HTMLBody := '<b>Bold line</b>' +
'<TABLE border="1">' +
'<TR><TH>Column 1 1<TH>Column 2' +
'<TR><TH>Value 1<TH>Value 2' +
'<TR><TH align="right">' + FORMAT(123456789,258) + '<TH>' + 'My name is jens' +
'</TABLE>'
+ lMailItem.HTMLBody;
Though it would be nice with the possibility of adding the (HTML) body line-by-line like the 'AddBodyLine' in codeunit 397??
@jensthomsen, bump
Just adding som HTML code in the 'AddBodyLine' function of codeunit 397 works for me (when opening the Outlook message HTML encoding must be true):
Mail.AddBodyline('<b>Bold Line</b>');
I'm not that kind of a "shark" in HTML coding, but I think that codeunit 397 does some of the encoding to HTML for you.
<edit>you are working with a different version<edit>
sorry, that I didn't mention to set the var's for RunOnClient=Yes.
Did you try to add the html Body to a local var of type Text without length and then assign it to the dotnet-body property?
Otherwise you'll have to create a simple dotnet class with a method, that takes more body lines.
Thx again for helping me out:-)