Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendmail via outlook complete with body and default signature

Status
Not open for further replies.

kennycad

Technical User
Jan 26, 2005
52
AU

Hi,

Am putting together a vb.net application in which an email is generated (to, subject, body and attachment) then displayed (as it would typically be using outlook) for the user to add further custom information. The issue i have is with the inculsion of the default signature.

It all works however as a result of the oMail.body = "body text" the default signature does not show up when displayed. If i remove the oMail.body portion of code it does.

How do I get the outlook message up for preview with both an automated body and default signature?

Code as follows:

Dim oOutL As New Outlook.Application
Dim oMail As Outlook.MailItem
Dim oInsp As Outlook.Inspector

oMail = oOutL.CreateItem(Outlook.OlItemType.olMailItem)

oMail.To = ""
oMail.Subject = "My Subject"

''if this line of code is included the defaul signature does not show up when displayed
'oMail.Body = "My Body"

oInsp = oMail.GetInspector
oMail.Display()

Thanks in advance
 

What you need to do is call Outlook.MailItem.Display() before you set the body text with Outlook.MailItem.Body, and you need to append the message's existing body (which will have the signature) to the body text you are providing.

Dim oOutL As New Outlook.Application
Dim oMail As Outlook.MailItem
Dim oInsp As Outlook.Inspector

oMail = oOutL.CreateItem(Outlook.OlItemType.olMailItem)

oMail.To = ""
oMail.Subject = "My Subject"

oInsp = oMail.GetInspector
oMail.Display()

[red]oMail.Body = "My Body" & oMail.Body[/red]



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 

jebensen.

thanks, this works however it changes the format of the signature and i lose images etc. I also get the message that "a program is trying to access email addresses". Any idea's on how to avoid both?


thanks
 
Well, I can't reproduce the "a program is trying to access email addresses" message, so I can't speak to that. As to the formatting in the signature, I found this link:


This page tells how to use the actual signature files that are created by Outlook. The code on that page is VBA, but it should give you a good starting point to do something similar in VB .NET.

One issue I see is that users can create multiple signatures in Outlook, and each is saved with its own name. I'm not sure if you can determine which is the default signature or which on is actually in use, but as far as I can tell this seems to be about the only way of keeping the format of the signature.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top