Ankur Kumar
New Member
Hi,
Please help when i am sending email via using VBA coding it automatically rename the file name as i want to be but in the original location it remain same name just when i a send email it automatically rename here is my coding please help me out, when i need to apply that code to get my result.
Please help when i am sending email via using VBA coding it automatically rename the file name as i want to be but in the original location it remain same name just when i a send email it automatically rename here is my coding please help me out, when i need to apply that code to get my result.
Code:
Sub Email_VCC_BANK_REPORT()
' Don't forget to copy the function GetBoiler in the module.
' Working in Office 2000-2016
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H4><B>Hi Team,</B></H4>" & _
"Please find the bank report as attached.<br>"
'Change only Mysig.htm to the name of your signature
SigString = Environ("appdata") & _
"\Microsoft\Signatures\Ankur.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.Display
.To = ""
.CC = ""
.BCC = ""
.Subject = "VCC BANK REPORT DATED" & " " & Format(Date - 1, "dd/MM/yyyy")
.HTMLBody = strbody & "<br>" & Signature
.Attachments.Add ""
.Display 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Function GetBoiler(ByVal sFile As String) As String
'Dick 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
Last edited by a moderator: