Hi all
I have a worksheet that users can send a copy to an individualise it adds the body text and I want to add the signature but it does not do it my code is as follow any help would be very much appreciated many thanks. As I have said this all work apart from adding the signature I have looked as so many forum and I just cant get it to add the body text and signature it always seems to be one or the other.
Private Sub EmailButton1_Click()
'Do not forget to change the email ID
'before running this code
Dim OlApp As Object
Dim NewMail As Object
Dim TempFilePath As String
Dim FileExt As String
Dim TempFileName As String
Dim FileFullPath As String
Dim FileFormat As Variant
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Dim Signature As String
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Wb1 = ThisWorkbook
ActiveSheet.Copy
Set Wb2 = ActiveWorkbook
'Below code will get the File Extension and
'the file format which we want to save the copy
'of the workbook with the active sheet.
With Wb2
If Val(Application.Version) < 12 Then
FileExt = ".xls": FileFormat = -4143
Else
Select Case Wb1.FileFormat
Case 51: FileExt = ".xlsx": FileFormat = 51
Case 52:
If .HasVBProject Then
FileExt = ".xlsm": FileFormat = 52
Else
FileExt = ".xlsx": FileFormat = 51
End If
Case 56: FileExt = ".xls": FileFormat = 56
Case Else: FileExt = ".xlsb": FileFormat = 50
End Select
End If
End With
'Save your workbook in your temp folder of your system
'below code gets the full path of the temporary folder
'in your system
TempFilePath = Environ$("temp") & "\"
'Now append a date and time stamp
'in your new file
TempFileName = "FMT 103" & "-" & Format(Now, "dd-mmm-yy")
'Complete path of the file where it is saved
FileFullPath = TempFilePath & TempFileName & FileExt
'Now save your currect workbook at the above path
Wb2.SaveAs FileFullPath, FileFormat:=FileFormat
'Now open a new mail
Set OlApp = CreateObject("Outlook.Application")
Set NewMail = OlApp.CreateItem(0)
On Error Resume Next
With NewMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Resign for MT Order on F/MT 103"
.Body = "Hello, you are required to resign MT Order" & vbCrLf & vbCrLf & _
"MT Orders are re-signed annually on the F/MT 103." & vbCrLf & _
"Print F/MT 103 and sign." & vbCrLf & _
"You are also required to produce a new Driving Licence (DL) Summary Sheet form" & vbCrLf & _
"Click on Start now." & vbCrLf & _
"Enter DL No, National Insurance No, & Post Code (That is on your DL)." & vbCrLf & _
"Click I agree in the declaration box." & vbCrLf & _
"Click View now." & vbCrLf & _
"Click Get you check code tab for right." & vbCrLf & _
"Click Get a code." & vbCrLf & _
"Click Print or save a driving summary." & vbCrLf & _
"Click open and print this page." & vbCrLf & vbCrLf & _
"(This is also required for the old-style paper licences)." & vbCrLf & _
"If your High Way Code Test (HWCT) date has expired, you can undertake a new test at the following web address." & vbCrLf & _
"On completion of test print a sign." & vbCrLf & _
"Scan all signed document along with DL card Front & Back and send to Wing HQ for processing." & vbCrLf & vbCrLf & _
"Many Thanks" & vbCrLf & vbCrLf & Signature
.Attachments.Add FileFullPath '--- full path of the temp file where it is saved
.Display
'.Send 'or use .Display to show you the email before sending it.
End With
On Error GoTo 0
'Since mail has been sent with the attachment
'Now close and delete the temp file from the
'temp folder
Wb2.Close savechanges:=False
Kill FileFullPath
'set nothing to the objects created
Set NewMail = Nothing
Set OlApp = Nothing
'Now set the application properties back to true
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Bookmarks