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

LVL 13
duncanb7Asked:
Who is Participating?
 
Chris BottomleySoftware Quality Lead EngineerCommented:
I note you are not quitting the outlook instance.

As for the security warning:

1. You can modify your code to use redemption: | http://www.dimastr.com/redemption/
2. You can use an outlook add-in i.e: | http://www.mapilab.com/outlook/security
3. Or finally you can use clickyes | http://www.contextmagic.com/

From my perspective ... if you do a lot of VBA programming then redemption is a good solution ... personally I rarely use it now.
I now use the maplab security add-in of option 2.  The first time you do something it asks if you want to continue, and if you click the always take this option it never bothers you again ... and it's free for both personal and commercial usage.
3. Personally I have never used clickyes but there are those who advocate so I include it for information

Chris
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
app.quit
Set app = Nothing
Set itm = Nothing

End Function

Open in new window

0
 
duncanb7Author Commented:
I think I can handle  your 3 option suggestion, Could you answer me the first question, please advise?
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
The expectation is that with the clean quit the outlook mail will be sent immediately ... did you check?

Chris
0
 
duncanb7Author Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.