Avatar of morrisbo
morrisbo
 asked on

sending email to outlook from vb6 program - warning messages in outlook

I am developing a vb6 application that uses outlook to send an email from within the vb6 program.  The message is sent but only after outlook displays 2 warning messages about "A program is trying to access e-mail addresses you have stored in outlook" and "A program is trying to automatically send email on your behalf".

I do not want the error messages to pop up.  See the attached file for screen snapshot of the warning messages.  Also, I have checked the Microsoft Outlook 11.0 Object Library.

Thanks for any help on how I can eliminate the messages.

Morrisbo
Private Sub mnuEmailTest_Click()
Dim oApp As Object 'Outlook
Dim oNewMail As Object

Set oApp = New Outlook.Application
Set oNewMail = oApp.CreateItem(olMailItem)
With oNewMail
   .Display
   .Recipients.Add "mb@testwebsite.com"
   .Subject = "Subject here"
   .Body = "Text here"
   .Attachments.Add "c:\mypdf.pdf"
   .Send
End With
Set oNewMail = Nothing
Set oApp = Nothing
End Sub

Open in new window

OutlookMessages.jpg
Microsoft DevelopmentOutlook

Avatar of undefined
Last Comment
morrisbo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David Lee

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Shreedhar Ette

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Shreedhar Ette

morrisbo

ASKER
BlueDevilFan & Shreedhar

Thanks for the information

I was able to solve the problem by just changing the .Send item to .Display.

This change causes outlook to pop up with the email information filled in, ready to send.

I have included the code below.

Really appreciate your help with links to various documentation.

Had to look more on the internet to find the code snippet using outlook.Application.

Morrisbo
Sub SendEmail()

    Dim olApp As Outlook.Application
    Dim olMail As MailItem
    Dim CurrFile As String

    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    With olMail
        .To = "name@domain.net"
        .CC = "name2@domain2.com"
        .Subject = "These two files"
        .Body = "Body of email goes here
        .Attachments.Add "c:\My Documents\book.doc"
        .Display '.Send
    ---> just changed .Send to .Display
    End With

    Set olMail = Nothing
    Set olApp = Nothing

End Sub

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck