• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Microsoft Outlook security delay

I use the following code to send emails.

   Private Sub SendOutlook(ByVal subject As String, ByVal toe As String, _
     ByVal body As String, ByVal from As String)
      Dim Appl As Object
      Dim out As Object
         Appl = CreateObject("Outlook.Application")
         out = Appl.CreateItem(0)
         With out
            .Subject = subject
            .To = toe
            .Body = body
            'to use html in the email instead of plain text
            'use .HTMLBody instead of .body
         End With
      Catch ex As Exception
         MsgBox("Error " & Err.Number & ": " & ex.Message, MsgBoxStyle.Critical, "Error")
      End Try
   End Sub 'SendOutlook

This works fine, but I send many in a do loop with different messages.
Microsoft Outlook displays a message:
     A program is automatically trying to send an e-mail on your behalf.
     Do you want to allow this?
There is a long pause between each e-mail sent before I can respond Yes.  How can I eliminate this check?

  • 2
  • 2
  • 2
2 Solutions
Éric MoreauSenior .Net ConsultantCommented:
If you really want to use Outlook, you can automate the Yes by using a add-in: http://www.slipstick.com/outlook/esecup/admin.htm

But personnaly, I avoid using Outlook from applications. Have a look at the System.Web.Mail namespace that you can use even from Windows application.
using System.Web.Mail

MailMessage mail= new MailMessage();
mail.TO = "recip@theirdomain.com";
mail.From= "you@yourdomain.com";
mail.subject ="subject";
myMessage.Body ="BODY";

SmtpMail.SmtpServer = "your smtp server";
Imports System.Web.Mail

Dim mesg As MailMessage = New MailMessage ()

mail.To = "recip@theirdomain.com"
mail.From = "you@yourdomain.com"
mail.subject = "subject"
myMessage.Body = "BODY"

SmtpMail.SmtpServer = "your smtp server"

Sorry I wrote that in C#
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Harold_LominacAuthor Commented:
I can't import System.Web.Mail.  Is there something missing in my VB?
Harold_LominacAuthor Commented:
To emoreau:
I don't care what method I use to send the e-mails.  The methods should be available to the users.  Perhaps I could automate the "YES" in outlook, but there is a 5-second pause before it comes up.  That is a poor solution, if there is a better way.
Éric MoreauSenior .Net ConsultantCommented:
>>I can't import System.Web.Mail.  Is there something missing in my VB?

add a reference to System.Web

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now