Suppress dialog message when sending Outlook message through

I am programming against the Outlook com object in VB.NET 2005. When I apply the .Send method to the item, the following dialog box pops up and nothing will happen until the user replies. The only problem is I want this to be an automated process running on a disconnected account, so I cannot process message boxes. Anyone know of a way to supress this message through code? I know that programming the Word and Excel obect models have a DisplayAlerts property that can be set to False, but it does not appear that such a property exists in the Outlook object model.

Title: Microsoft Office Outlook

A program is trying to automatically send an e-mail on your behalf.
Do you want to allow this?

If this is unexpected, it may be a virus and you shoudl choose "No".
LVL 15
Who is Participating?
David LeeConnect With a Mentor Commented:
Hi, dbbishop.

"Anyone know of a way to supress this message through code?"
There's is no way to suppress the message through code or any Outlook setting.  It is a security feature that Microsoft added to Outlook to stop the many viruses and worms written to use Outlook as a transport mechanism.  If you want to continue using Outlook to send from code, then there are two solutions to get around this.

1.  Use Outlook Redemption (  Redemption is a third-party library that allows you program around Outlook security.

2.  Use ClickYes (  ClickYes is a utility that sits in teh system tray and watches for Outlook's security warning dialogs.  When one pops up it clicks the Yes button for you.
dinomixConnect With a Mentor Commented:
Here is some information about several ways to do this.

I have done this personally a few years ago and found that using SMTP directly is the easiest way to go, this bypasses outlook alltogether and sends the message driectly. Microsoft has this encapsulated into CDO ( ) which provides easy smtp functionallity. There are also several 3rd party objects that will bypass this. The reason it is so difficult is because this is a security feature that is designed not to be bypassed so that a malicious program cannot send email on your behalf.
dbbishopAuthor Commented:
Do you have an example of instantiating a CDO object, populating it and sending a message? I've added a reference to the MS CDO 1.21 Library in my project, but I'm not sure where to go from there. As I indicated, I'm programming in VB.NET 2005.

I need to set Subject, message text, To, CC, and add an attachment. There will be multiple email addresses in both the To and CC addresses, so I assume they are separated by commas?
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

SUB sendmail( fromWho, toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds

Const cdoSendUsingPort = 2

Set objCDO = new cdo.message
Set iConf = new cdo.configuration
Set Flds = iConf.Fields
With Flds
           .Item(cdoSendUsingMethod) = cdoSendUsingPort
           .Item(cdoSMTPServer) = "mail-fwd"          
           .Item(cdoSMTPServerPort) = 25
           .Item(cdoSMTPconnectiontimeout) = 10
End With

Set objCDO.Configuration = iConf

objCDO.From = fromWho
objCDO.To = toWho
objCDO.Subject = Subject
objCDO.TextBody = Body


Something like that, i copied the code from this site (see link below), it is for web but should work with as typed above. You can use intellisense to play around with the properties, there should be an attachment property that will allow you to attach files. I don't have studio on this pc so i cannot test for you but should be straightforward.
dbbishopAuthor Commented:
I get no intellisense against the CDO object. I'll play around but in you need to specify the datatype in a Dim statement (i.e. Dim objCDO As CDO ), but I get an error that CDO is not a defined type.
dbbishopAuthor Commented:
ClickYes works like a CHARM! Thanks.

dinomix: Thanks for the info. Sorry I couldn't get CDO to work, but you initially pointed ot the problem.
David LeeCommented:
You're welcome.  Glad I could help.
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.