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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.