Solved

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

Posted on 2013-02-05
3
246 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 48

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
clear from current cell down not up 2 11
TT Column Arrange 10 28
Populate data based on a  criteria 2 16
MIN, using ARRAY 4 16
A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now