Microsoft Outlook security delay

Posted on 2004-11-21
Last Modified: 2010-04-23
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?

Question by:Harold_Lominac
    LVL 69

    Expert Comment

    by:Éric Moreau
    If you really want to use Outlook, you can automate the Yes by using a add-in:

    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.
    LVL 2

    Expert Comment

    using System.Web.Mail

    MailMessage mail= new MailMessage();
    mail.TO = "";
    mail.From= "";
    mail.subject ="subject";
    myMessage.Body ="BODY";

    SmtpMail.SmtpServer = "your smtp server";
    LVL 2

    Accepted Solution

    Imports System.Web.Mail

    Dim mesg As MailMessage = New MailMessage ()

    mail.To = ""
    mail.From = ""
    mail.subject = "subject"
    myMessage.Body = "BODY"

    SmtpMail.SmtpServer = "your smtp server"

    Sorry I wrote that in C#

    Author Comment

    I can't import System.Web.Mail.  Is there something missing in my VB?

    Author Comment

    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.
    LVL 69

    Assisted Solution

    by:Éric Moreau
    >>I can't import System.Web.Mail.  Is there something missing in my VB?

    add a reference to System.Web

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now