Hi Linda
To insert your Signature into the Emails replace your ENTIRE Code with this Code. You'll need to modify this line to the name of your Signature
SigString = Environ("appdata") & _
"\Microsoft\Signatures\jas.txt" '<---Modify jas.txt to the name of your Signature
This change may or may not work depending on your operating system and what version of Outlook your using. I'm running XP with Outlook 2007 and this works for me.
You don't need to do anything else (the Button Code remains as is).
Let me know of issues.
Option Explicit
Dim myStore As String
Dim ws As Worksheet
Dim rng As Range
Dim SigString As String
Dim Signature As String
Sub test()
For Each ws In ThisWorkbook.Sheets
If ws.Name <> "CONTACTS" And ws.Name <> "DATA" Then
With ws
myStore = .Range("A6")
With Sheets("CONTACTS").Range("A:A")
Set rng = .Find(What:=myStore, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
If rng.Offset(0, 3).Value Like "?*@?*.?*" Then
Call Create_PDF
Else
GoTo SkipMe
End If
End If
End With
End With
End If
SkipMe:
Next ws
End Sub
Sub Create_PDF()
Dim strSubject As String
Dim strBody As String
Dim strTo As String
Dim strCC As String
Dim Filename As String
Dim myPath As String
myPath = ThisWorkbook.Path & "\"
strSubject = "Enter Your Subject Here" '<----------------
strBody = "Enter Your Body Message Here" '<----------------
strTo = rng.Offset(0, 3).Value
strCC = ""
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
myPath & myStore & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Filename = myPath & myStore & ".pdf"
If Filename <> "" Then
RDB_Mail_PDF_Outlook Filename, strTo, strCC, strSubject, strBody, False '<---Change to True to Auto Send Mail
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
Kill Filename
End Sub
Function RDB_Mail_PDF_Outlook(FileNamePDF As String, strTo As String, strCC As String, _
strSubject As String, strBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Change only Mysig.txt to the name of your signature
SigString = Environ("appdata") & _
"\Microsoft\Signatures\jas.txt" '<---Modify jas.txt to the name of your Signature
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = strTo
.CC = strCC
.BCC = ""
.Subject = strSubject
.Body = strBody & vbNewLine & vbNewLine & Signature
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function
Function GetBoiler(ByVal sFile As String) As String
'**** Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Bookmarks