Link to home
Create AccountLog in
Avatar of duncanb7
duncanb7

asked on

send email in VBA

Dear Expert,

I found one strange problem, when I am doing sent email to my client in VBA,
VBA code at .send (see attach code)  will come one dialog box to warn and ask me whether to continue to
send the message that might be virus" and then I manually  press "yes to finish
the rest  the VBA code. The Client doesn't recevie any email until
I re-open outlook software and quit it. THe client can receive the email right away. Why ?

and the other question, how to avoid the message warning dialog window, and I try
to set Application.DisplayAlerts = False but it is not working at all

Please advise for those two question and view my attach VBA code for email send



Function sendmail()
Set app = CreateObject("outlook.application")
Set itm = app.CreateItem(0)
Application.DisplayAlerts = False

With itm
.Subject = "dail report"
.To = "duncanuk9@hotmail.com.hk"
.Body = "daily last report"
'.Display
.Send  """"""""""""""""""Warning dialog window will came out to ask me whether to continue ? 
End With
Set app = Nothing
Set itm = Nothing

End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of duncanb7
duncanb7

ASKER

I think I can handle  your 3 option suggestion, Could you answer me the first question, please advise?
The expectation is that with the clean quit the outlook mail will be sent immediately ... did you check?

Chris
THanks for you,

THe first question is solved,
because I open Excel 2003 VB
for coding so I need to open
outlook(but no need to quit) and
the client receive any email if
outlook is not quit.

So I guess I run the code directly in
outlook VBA is working easier than in
Excel 2003 VBA +outlook