See
http://www.outlookcode.com/d/sec.htm for your options with regard to the "object model guard" security in Outlook 2000 SP2 and later versions.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Microlong®" <(E-Mail Removed)> wrote in message news:AD43A9CD-3F25-40F9-97C5-(E-Mail Removed)...
> Currently I encountered a problem when I attempt to access outlook email
> address book.
> I use VB6 code call cdo 1.2.1 object. The mails address need to resolve.
> however I got dialogue box while resolving the email address. The Alert
> message said: A program is try to access email-address you have stored in
> outlook. Do you want to
> allow this?
> My code is as follows:
>
> Private Sub Form_Load()
> 'Body of email message
> Dim msgBody As String
> Dim msgMailReceiver
> msgBody = "A mail for test"
> msgMailReceiver = "v-dawang"
> 'Call our function with recipient, message and subject
> MySendMail msgMailReceiver, msgBody, "Automated Message."
> MsgBox "Deliever OK!!"
> Unload Me
> End Sub
> Sub MySendMail(recipient, msg, subject)
> On Error GoTo errorhandle
> Dim objSession, oInbox, colMessages, oMessage, colRecipients
> Dim strProfile As String
> Set objSession = CreateObject("MAPI.Session")
> strProfile = "default outlook profile"
> If strProfile <> "" Then
> objSession.Logon strProfile
> Else
> Exit Sub
> End If
> Set oInbox = objSession.Inbox
> Set colMessages = oInbox.Messages
> Set oMessage = colMessages.Add()
> Set colRecipients = oMessage.Recipients
> colRecipients.Add recipient
> colRecipients.Resolve (True) '(Dialogue will raise!)
> oMessage.subject = subject
> oMessage.Text = msg
> oMessage.Send
> objSession.Logoff
> Set objSession = Nothing
> Exit Sub
> errorhandle:
> MsgBox "Input error!!"
> End Sub
>
> Welcome any suggestion!!
> thanks.
> Microlong
> --
> Developer
> QA Dashboard
> Microsoft China Development Centre