Solved

How is it possible to include a signature with an email sent with code from Excel?

Posted on 2013-02-05
3
248 Views
Last Modified: 2013-02-06
I have been using some code for a long while for sending emails from Excel as attached.
This has worked fine.

Recently our company has devised a signature "OH Signature" that they would like to be sent with all emails.
Is it possible to include this within the code?

Thanks
Des

Dim OutApp As Object
Dim OutMail As Object
Dim StrBody As String
Dim filePath As String
Dim XPath As String

StrBody = Line1 & "<br>" & _
Line2 & "<br>" & _
Line3 & "<br>" & _
Line4 & "<br>" & _
Line5 & "<br>" & _
Line6 & "<br>" & _
Line7 & "<br>" & _
Line8 & "<br>" & _
Line9 & "<br>" & _
Line10 & "<br><br><br>"

filePath = Sheets("Configuration").Range("B5").Value & "\" & FolderSave
XPath = filePath & "\" & Range("G4").Value & ".pdf"

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Range("D9").Value
.CC = ""
.BCC = ""
.Subject = EMailSub
.ReadReceiptRequested = True
.Importance = 2
.HTMLBody = StrBody
If (filePath) <> "" Then
.Attachments.Add XPath
End If

Open in new window

0
Comment
Question by:spar-kle
3 Comments
 
LVL 15

Assisted Solution

by:gplana
gplana earned 100 total points
ID: 38854494
I think this code can help you:

set inspect1 = myitem.GetInspector
inspect1.CommandBars.ActiveMenuBar.Controls("Insert").Controls("Signat ure").Controls("Sig1").execute

Open in new window


This code is extracted from this link: http://www.bigresource.com/VB-Adding-signature-to-Outlook-email-through-VBA-X11mZ0uG2F.html

Hope it helps.
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 400 total points
ID: 38854523
0
 

Author Closing Comment

by:spar-kle
ID: 38856191
Thanks for your help, really appreciated.

I found a simple approach that seems to work, is placing...
.HTMLBody = StrBody & .HTMLBody
...after the .Display as below.

I found this solution @ http://www.pcreview.co.uk/forums/insert-email-signature-excel-vba-t3922691.html


With OutMail
.To = Range("D9").Value
.CC = ""
.BCC = ""
.Subject = EMailSub
.ReadReceiptRequested = True
.Importance = 2
If (filePath) <> "" Then
.Attachments.Add XPath
End If
.Display  
.HTMLBody = StrBody & .HTMLBody
End With
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Route Recommendation 18 31
Automatic sort formula 8 49
conditional formatting 4 41
Excel VBA 4 26
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question