Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-02-05
3
Medium Priority
?
270 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 400 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 53

Accepted Solution

by:
Rgonzo1971 earned 1600 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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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.

610 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