Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-02-05
3
250 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 50

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

808 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