Including signature in email created with Add-In

N

niall.ogrady

Hi everyone,

I'm currently writing an Outlook add-in that creates an email for a
user after they make a few selections on a template form.

One of the things I would like to be able to do is include the
signature.

On the form there is a text box for the user to paste in the text they
want to include. The issue is, if the user leaves this box empty and
creates the email the signature will appear. However if they include
any text at all in the box, the signature doesn't appear.

I'm running Windows XP SP 2, Outlook 2003 and Visual Studio 2005.

Here is the section of code:

'*Build the Email*'
'Add user Text
myMail.Body = TextBox1.Text

I've had a few hours of searching for an answer to this, and from other
posts in this group its clear that the signature is automatically
included when a mail is created (which is the case for me) What I would
like to know is if there is any way to add text to the mail without
over writing that signature?

Thanks in Advance

Niall
 
K

Ken Slovak - [MVP - Outlook]

If you set .Body = whatever you will always overwrite what was there before.
Append or prepend your text:

..Body = .Body & TextBox1.Text 'append

or

..Body = TextBox1.Text & .Body 'prepend
 
N

niall.ogrady

Hi Ken,

I had originally thought that this worked, but I'm afraid it doesn't.

Whether I prepend or append like you suggested, I still end up with no
signature in the new mail. Is there anything I need to import to get
this to work?

e.g. even setting .body = .body produces an email without the
signature. However, when I don't set .Body to anything, the signature
will appear.

I'm running Windows XP SP 2, Visual Studio 2005 and Office 2003. Is it
possible I'm missing something obvious, or is what I'm trying just not
possible?

Thanks in advance.
 
S

Sue Mosher [MVP-Outlook]

The signature won't appear until you display the message, so you would need to use something more like:

myMail.Display
myMail.Body = TextBox1.Text & myMail.Body

Of course, if you want to preserve formatting in HTML and RTF messages, it gets a lot more complicated.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

niall.ogrady

Hi Sue,

After doing what you suggested I can now display the signature along
with any text.

However, you must have read my mind because I would like to be able to
preserve the formatting. Would it be possible for you to point me in
the direction of an example or a tutorial on this? I've googled it for
the past few minutes with no luck. If you don't have anything to hand
it's no problem, there's no need for me to take up too much of your
time on this. (This isn't essential, more like a nice touch).

Many thanks.
 
S

Sue Mosher [MVP-Outlook]

For HTML messages, use HTMLBody, not Body and insert your text into the fully tagged HTML content that already exists on the item.

For RTF messages, there are no straightforward solutions for all scenarios. See http://www.outlookcode.com/d/formatmsg.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

niall.ogrady

Thanks for the help!
Sue said:
For HTML messages, use HTMLBody, not Body and insert your text into the fully tagged HTML content that already exists on the item.

For RTF messages, there are no straightforward solutions for all scenarios. See http://www.outlookcode.com/d/formatmsg.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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