Solved

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

Posted on 2013-02-05
3
251 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

696 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