Pause VBA until email send completes

Hi,

I'm dumping out a chart to a png file and then emailing the png file. Then I want to delete the pgn file. Currently, though, my code deletes the png file before it gets attached to the email. How do I pause VBA until the email send completes?

My code snippet

With olmail
.to = "someone@myoffice.com"
.HTMLBody = .HTMLBody & "< img src='c:\dump\chart1.png'>"
.Subject = "Average Response Time " & Format(Date - 1, "Long Date")
.send
End With

Set OutMail = Nothing
Set OutApp = Nothing

With New FileSystemObject
If .FileExists("C:\dump\Chart1.png") Then
.DeleteFile "C:\dump\Chart1.png"
End If
End With

Vikas Verma's picture

Try this

Hi Dear,

Use this..hope it will help you

Application.Wait (Now + TimeValue("0:00:05"))