Link to home
Start Free TrialLog in
Avatar of Ferhat Er
Ferhat Er

asked on

Need help with VBScript adding Signature

I have the following script and I need it to also pick up the Outlook signature when sending.
I know is can while in Outlook click on insert and add the signature, but was wondering if I can add this to the VB Script.

Dim datYesterday, strDDMMYY, myStart, myMessage, myattachment, strEmail

datYesterday = DateAdd("d", -1, Now())
strDDMMYY = Right("0" & Day(datYesterday), 2) & Right("0" & Month(datYesterday), 2) & Right(Year(datYesterday), 2)
strEmail = Right("0" & Day(datYesterday), 2) & "/" & Right("0" & Month(datYesterday), 2) & "/" & Right(Year(datYesterday), 2)

myattachment = "N:\Users\Production\ops\Ops Documents\PCOMB Errors\Pcomb Error Report " & strDDMMYY &".doc"
myMessage = "PCOMB Timings & Error Report " & strDDMMYY

Set outlookApp = CreateObject("Outlook.Application")

olMailItem = 0
Set newMessage = outlookApp.CreateItem(olMailItem)

newMessage.To = "test@hotmail.com"
newMessage.Subject = myMessage
newMessage.Attachments.Add "N:\Users\Production\ops\Ops Documents\Spreadsheets and templates\PCOMB_Timings.xls"
newMessage.Attachments.Add "N:\Users\Production\ops\Ops Documents\PCOMB Errors\Pcomb Error Report " & strDDMMYY &".doc"
newMessage.Body = "Good Morning," & vbCrLf & vbCrLf & "Please find attached the PCOMB Timings and Error Report for " & strEmail & "." & vbCrLf

newMessage.Display


Any help is appreciated.

Kind Regards,

Ferhat ER
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As we are setting the HTMLBody of the email, not the Body, vbCrLf will not be recognized. Instead you have to construct HTML...

    .HTMLBody = "Good Morning,<br><br>Please find attached the PCOMB Timings and Error Report for " & strEmail & ".<br>" & .HTMLBody

Open in new window

BTW, I appreciate you endorsing my comment, but that's not entirely how it works. You need to accept a comment as the answer in order to show proper appreciation. See here for more info.