|
|
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
|
|
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
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm
<niall.ogrady[ at ]gmail.com> wrote in message news:1149087933.184816.87780[ at ]j55g2000cwa.googlegroups.com...
[Quoted Text] > 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 >
|
|
Thanks Ken, that seems to have worked perfectly!
|
|
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.
|
|
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 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx <niall.ogrady[ at ]gmail.com> wrote in message news:1151322843.076066.177120[ at ]i40g2000cwc.googlegroups.com...
[Quoted Text] > 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. >
|
|
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.
|
|
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 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx <niall.ogrady[ at ]gmail.com> wrote in message news:1151328601.457401.168800[ at ]p79g2000cwp.googlegroups.com...
[Quoted Text] > 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. >
|
|
Thanks for the help! Sue Mosher [MVP-Outlook] wrote:
[Quoted Text] > 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 > http://www.turtleflock.com/olconfig/index.htm> and Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx> > <niall.ogrady[ at ]gmail.com> wrote in message news:1151328601.457401.168800[ at ]p79g2000cwp.googlegroups.com... > > 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. > >
|
|
|