Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   macro to include email signature (http://www.outlookbanter.com/outlook-vba/102649-macro-include-email-signature.html)

steve sharpe May 20th 10 12:04 PM

macro to include email signature
 
I have attached the following code to a button on the quick access bar in Outlook. It does all I want except that "body text" erases my default signature. Is there some additional code I could include that would complete the email with my default signature? The default signature uses various fonts sizes and colours. Thanks for any help.

Sub inspector()

Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Body = "body text"
myAttachments.Add "C:\Documents and settings\etc
myItem.Display

End Sub

Ken Slovak - [MVP - Outlook] May 20th 10 07:33 PM

macro to include email signature
 
Call Display() before you add anything to the body. The signature is added
after the item is opened.

If you want to have your addition before any signature then after you call
Display() use code like this:

myItem.Body = "body text" & myItem.Body

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"steve sharpe" wrote in message
...

I have attached the following code to a button on the quick access bar
in Outlook. It does all I want except that "body text" erases my
default signature. Is there some additional code I could include that
would complete the email with my default signature? The default
signature uses various fonts sizes and colours. Thanks for any help.

Sub inspector()

Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Body = "body text"
myAttachments.Add "C:\Documents and settings\etc
myItem.Display

End Sub




--
steve sharpe



steve sharpe May 21st 10 12:07 PM

Hi Ken
Thankyou for youir reply. What have I done wrong? I think I have altered my code as you suggested but it does not make any difference. Here's what I wrote... Would you be kind enough to point out my mistake?

Sub InsertMySig()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Display
myItem.Body = "body text" & myItem.Body
myAttachments.Add "C:\Documents and settings\etc"
End Sub

I look forward to hearing from you.
Best wishes

Steve

Quote:

Originally Posted by Ken Slovak - [MVP - Outlook] (Post 349233)
Call Display() before you add anything to the body. The signature is added
after the item is opened.

If you want to have your addition before any signature then after you call
Display() use code like this:

myItem.Body = "body text" & myItem.Body

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"steve sharpe" wrote in message
...

I have attached the following code to a button on the quick access bar
in Outlook. It does all I want except that "body text" erases my
default signature. Is there some additional code I could include that
would complete the email with my default signature? The default
signature uses various fonts sizes and colours. Thanks for any help.

Sub inspector()

Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Body = "body text"
myAttachments.Add "C:\Documents and settings\etc
myItem.Display

End Sub




--
steve sharpe


Ken Slovak - [MVP - Outlook] May 21st 10 04:25 PM

macro to include email signature
 
I'm not sure. Let's see what happens first if you comment out the line
myItem.Body = "body text" & myItem.Body. Do you get the signature then? If
so and the body format is HTML, then see if it helps to use this line
instead:

myItem.HTMLBody = "body text" & myItem.HTMLBody

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"steve sharpe" wrote in message
...

Hi Ken
Thankyou for youir reply. What have I done wrong? I think I have
altered my code as you suggested but it does not make any difference.
Here's what I wrote... Would you be kind enough to point out my
mistake?

Sub InsertMySig()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Display
myItem.Body = "body text" & myItem.Body
myAttachments.Add "C:\Documents and settings\etc"
End Sub

I look forward to hearing from you.
Best wishes

Steve



steve sharpe June 2nd 10 11:41 AM

Thanks Ken. That worked Your'e a star!

Regards

Steve

Quote:

Originally Posted by Ken Slovak - [MVP - Outlook] (Post 349299)
I'm not sure. Let's see what happens first if you comment out the line
myItem.Body = "body text" & myItem.Body. Do you get the signature then? If
so and the body format is HTML, then see if it helps to use this line
instead:

myItem.HTMLBody = "body text" & myItem.HTMLBody

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"steve sharpe" wrote in message
...

Hi Ken
Thankyou for youir reply. What have I done wrong? I think I have
altered my code as you suggested but it does not make any difference.
Here's what I wrote... Would you be kind enough to point out my
mistake?

Sub InsertMySig()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "Status Report"
myItem.Display
myItem.Body = "body text" & myItem.Body
myAttachments.Add "C:\Documents and settings\etc"
End Sub

I look forward to hearing from you.
Best wishes

Steve



All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com