Email signature using Outlook COM object model

J

Jeff

Can someone confirm that the Outlook 2003 COM object model does not
provide a way to programmatically get, modify, or remove the signature
line of an email?

Furthermore, it doesn't look like Redemption RDO supports manipulating
the signature line either (http://www.google.com/search?q=signature
+site%3Ahttp%3A%2F%2Fwww.dimastr.com%2Fredemption
%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-
US:blush:fficial&client=firefox-a).

I've noticed that a SafeMailItem will contain the signature line as
long as I don't modify the Body property. Has anyone else noticed
that?

Thanks,
Jeff
 
S

Sue Mosher [MVP-Outlook]

It certainly is possible to add a signature to an email message. If Word is the editor, it's also easy to remove it, because it's exposed as a Bookmark object. See http://www.outlookcode.com/codedetail.aspx?id=615. If Word is not the email editor, the signature is not distinguished in any way from the rest of the text.
 
J

Jeff

Thanks for the link.

I did not see the text of the signature in the value of the Body
property of Redemption's SafeMailItem, as one might expect. Based on
that test, also I assume that the signature would not appear in
RDO.RDOMail.Body, .HTMLBody, .RTFBody either, but I didn't take the
time to test those. I didn't see a ".Signature" property or equivalent
in Outlook COM, Redemption Safe* items, or Redemption RDO objects. Am
I missing something?

In my install of Outlook 2003 (Word as Editor, HTML format by
default) the signature line is getting added as long as I don't
manipulate the SafeMailItem.Body property. Is that expected?

Thanks,
Jeff
 
S

Sue Mosher [MVP-Outlook]

There is no Signature property. The operations I describe do not depend on there being one.

It might help if you showed some code. Without that, we have no way of knowing in what order you're performing operations, etc. If you overwrite the Body property, for example, any signature that already exists is going to be replaced by your new Body text.

--
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 said:
Thanks for the link.

I did not see the text of the signature in the value of the Body
property of Redemption's SafeMailItem, as one might expect. Based on
that test, also I assume that the signature would not appear in
RDO.RDOMail.Body, .HTMLBody, .RTFBody either, but I didn't take the
time to test those. I didn't see a ".Signature" property or equivalent
in Outlook COM, Redemption Safe* items, or Redemption RDO objects. Am
I missing something?

In my install of Outlook 2003 (Word as Editor, HTML format by
default) the signature line is getting added as long as I don't
manipulate the SafeMailItem.Body property. Is that expected?

It certainly is possible to add a signature to an email message. If Word is the editor, it's also easy to remove it, because it's exposed as a Bookmark object. See http://www.outlookcode.com/codedetail.aspx?id=615. If Word is not the email editor, the signature is not distinguished in any way from the rest of the text.
 
J

Jeff

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.

Thanks for your patience.

jb
 
S

Sue Mosher [MVP-Outlook]

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.
 
D

Dmitry Streblechenko

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 said:
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.
 
G

Gunjan

Hi Dmitry,

Can you please explain in detail how to touch MailItem.GetInspector property?

Regards,
Gunjan



Dmitry Streblechenko wrote:

The signature is also inserted if you touch the MailItem.
24-Oct-07

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, CD
and MAPI Developer Too


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

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


Previous Posts In This Thread:

Email signature using Outlook COM object model
Can someone confirm that the Outlook 2003 COM object model does no
provide a way to programmatically get, modify, or remove the signatur
line of an email

Furthermore, it doesn't look like Redemption RDO supports manipulatin
the signature line either (http://www.google.com/search?q=signatur
+site%3Ahttp%3A%2F%2Fwww.dimastr.com%2Fredemptio
%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en
US:blush:fficial&client=firefox-a)

I've noticed that a SafeMailItem will contain the signature line a
long as I don't modify the Body property. Has anyone else notice
that

Thanks
Jeff

It certainly is possible to add a signature to an email message.
It certainly is possible to add a signature to an email message. If Word
is the editor, it's also easy to remove it, because it's exposed as a
Bookmark object. See
http://www.outlookcode.com/codedetail.aspx?id=3D615. If Word is not the
email editor, the signature is not distinguished in any way from the
rest of the text.=2

--=2
Sue Mosher, Outlook MV
Author of Microsoft Outlook 2007 Programming
Jumpstart for Power Users and Administrator
http://www.outlookcode.com/article.aspx?id=3D54=2


Thanks for the link.
Thanks for the link

I did not see the text of the signature in the value of the Bod
property of Redemption's SafeMailItem, as one might expect. Based o
that test, also I assume that the signature would not appear i
RDO.RDOMail.Body, .HTMLBody, .RTFBody either, but I didn't take th
time to test those. I didn't see a ".Signature" property or equivalen
in Outlook COM, Redemption Safe* items, or Redemption RDO objects. A
I missing something

In my install of Outlook 2003 (Word as Editor, HTML format b
default) the signature line is getting added as long as I don'
manipulate the SafeMailItem.Body property. Is that expected

Thanks
Jeff

There is no Signature property.
There is no Signature property. The operations I describe do not depend
on there being one.=2

It might help if you showed some code. Without that, we have no way of
knowing in what order you're performing operations, etc. If you
overwrite the Body property, for example, any signature that already
exists is going to be replaced by your new Body text.=2

--=2
Sue Mosher, Outlook MV
Author of Microsoft Outlook 2007 Programming
Jumpstart for Power Users and Administrator
http://www.outlookcode.com/article.aspx?id=3D54=2


It certainly is possible to add a signature to an email message. If Word =
is the editor, it's also easy to remove it, because it's exposed as a =
Bookmark object. See =
http://www.outlookcode.com/codedetail.aspx?id=3D615. If Word is not the =
email editor, the signature is not distinguished in any way from the =
rest of the text.=20



You've provided some great ideas on how to work w/ the signature, andI
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.

Thanks for your patience.

jb

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

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



The signature is also inserted if you touch the MailItem.
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


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



Good to know. Thanks!
Good to know. Thanks!=20

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


need to=20
insert the=20
call=20
COM
of


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Report Engine, Part 4
http://www.eggheadcafe.com/tutorial...45-8b37cb7f3186/wpf-report-engine-part-4.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top