View Single Post
  #7  
Old October 25th 07, 12:24 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Email signature using Outlook COM object model

The signature is also inserted if you touch the MailItem.GetInspector
property for the brand new messages with unmodified body. You do not need to
actually display the message. This is probably the easiest way to insert the
signature if you do not want to display the item first.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Sue Mosher [MVP-Outlook]" wrote in message
...
one would hope that getting MailItem.Body prior to
setting it would retrieve the signature line of an email.


It does, if (a) the user has an automatic signature set up and (b) you call
MailItem.Display first.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Jeff" wrote in message
ups.com...
You've provided some great ideas on how to work w/ the signature, and
I appreciate them. I'm just trying to focus in on what the Outlook COM
object model alone provides.

For a new email, if setting MailItem.Body erases the signature line of
an email, then one would hope that getting MailItem.Body prior to
setting it would retrieve the signature line of an email.

It'd be nice to be able to do something like this:

pseudocode snippet:

//create a new mail item
MailItem m = folder.Item.Add(OlItemType.olMailItem);

//store off the signature line (if the user has the option on):
String sig = m.Body;

//set Body to be my email content plus whatever the signature line is
m.Body = "my email content" + sig;

Contrary to how I'd like MailItem.Body to work, getting it prior to
setting it returns nothing (even if there is a signature line), and
setting it to something removes the signature line. I see no way to
set the Body of the email to my email content while at the same time
maintaining whatever signature line the user specified to appear in
new emails by default.



Ads