Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of morrisbo
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