• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I want to send attached with temp file name how can i do it

Ankur Kumar

New Member
Dear all,

i want once i send the email the attachement have temp file please help below is code.

' 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
    Dim TempFilePath As String
    Dim TempFileName As String
    TempFilePath = Environ$("temp") & "\"
    TempFileName = "VCC Bank Report dated " & " " & Format(-1, "dd-mmm-yy hh-mm-ss")

    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") & _

    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
        Signature = ""
    End If
    On Error Resume Next

    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "VCC BANK REPORT DATED" & " " & Format(Date - 1, "dd/MM/yyyy")
        .HTMLBody = strbody & "<br>" & Signature
                   .Attachments.Add "Z:\WORKING\Yearly Data\2019 - 2020\Accounting\MIS & Reporting\Weekly Reporting\VCC bank report.xlsm"
        .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
End Function
Last edited by a moderator:


Excel Ninja
Ankur Kumar
So ... what happen then You're running that macro?
Have You edit it?
.To seems to be empty
as well as
there are two times .Display, none .Send