M
Microlong®
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
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