MailItem.Recipients.Add (and every other Recipient/Recipients statement you
have aftger that) will always trigger the prompt. You need to work with
recipients solely in your Redemption SafeMailItem object:
objOutlookMsg.Save
Set objSafeMail = CreateObject("Redemption.SafeMailItem")
objSafeMail.Item = objOutlookMsg
' do stuff with objSafeMail.Recipients
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
Sue/Dmitry,
Sorry for the double post on the subject.
I am using M/S KB# 209948 to create the emails and
Redemption's code to send it. I think there is something
in the add recipients routine that causes the first
prompt to appear "A program is trying to access email
addresses you have stored in Outlook". I can't seem to
find it.
Sub SendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy
Davolio")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew
Fuller")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the
message.
.Subject = "This is an Automation test with
Microsoft Outlook"
.Body = "Last test - I promise." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add
(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
Any help will be appreciated.
Thanks,
Xcelsoft