How to disable outlook alert message in VB code?

G

Guest

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
 
D

Dan Mitchell

=?Utf-8?B?TWljcm9sb25nwq4=?= said:
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?

See http://www.outlookcode.com/d/sec.htm

-- dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top