Z
zbud
Trying to send email from MS Access 2003 using CDO 1.21 and the RTF DLL
in MS KB http://support.microsoft.com/?kbid=172038. This all works fine
except for dealing with Outlook 2003 security that advises a program is
trying to send a message on your behalf.
installed the Redemption library and am using the following code
snippet, which still works but still getting the security prompt. There
is also a "mapi_e_logon_failed" error is Outlook is not open.
Any help is appreciated.
Bud
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False, 0
' Create a new message
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Update
MessageID = objMessage.ID
'write the RTF String
bRet = writertf(objSession.Name, objMessage.ID, _
objMessage.StoreID, txtRTf)
If Not bRet = 0 Then
MsgBox "RTF Not Written Successfully", vbOKOnly, "VBSendRTF
Warning"
End If
'Clear our current variable
Set objMessage = Nothing
Set utils = CreateObject("Redemption.MAPIUtils")
utils.MAPIOBJECT = objSession.MAPIOBJECT
Set SafeObjMessage = CreateObject("Redemption.SafeMailItem")
' Get our message
Set SafeObjMessage = objSession.GetMessage(MessageID)
SafeObjMessage.Subject = strSubj
Set objRecipient = SafeObjMessage.Recipients.Add
objRecipient.Name = strEmail2
Set objAttachment = SafeObjMessage.Attachments.Add
objAttachment.Type = CdoFileData
objAttachment.ReadFromFile strPath
objAttachment.Source = strPath
objAttachment.Name = strReport
SafeObjMessage.Update
' Send the Message
SafeObjMessage.Send ShowDialog:=True
objSession.Logoff
utils.Cleanup
Set utils = Nothing
in MS KB http://support.microsoft.com/?kbid=172038. This all works fine
except for dealing with Outlook 2003 security that advises a program is
trying to send a message on your behalf.
installed the Redemption library and am using the following code
snippet, which still works but still getting the security prompt. There
is also a "mapi_e_logon_failed" error is Outlook is not open.
Any help is appreciated.
Bud
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False, 0
' Create a new message
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Update
MessageID = objMessage.ID
'write the RTF String
bRet = writertf(objSession.Name, objMessage.ID, _
objMessage.StoreID, txtRTf)
If Not bRet = 0 Then
MsgBox "RTF Not Written Successfully", vbOKOnly, "VBSendRTF
Warning"
End If
'Clear our current variable
Set objMessage = Nothing
Set utils = CreateObject("Redemption.MAPIUtils")
utils.MAPIOBJECT = objSession.MAPIOBJECT
Set SafeObjMessage = CreateObject("Redemption.SafeMailItem")
' Get our message
Set SafeObjMessage = objSession.GetMessage(MessageID)
SafeObjMessage.Subject = strSubj
Set objRecipient = SafeObjMessage.Recipients.Add
objRecipient.Name = strEmail2
Set objAttachment = SafeObjMessage.Attachments.Add
objAttachment.Type = CdoFileData
objAttachment.ReadFromFile strPath
objAttachment.Source = strPath
objAttachment.Name = strReport
SafeObjMessage.Update
' Send the Message
SafeObjMessage.Send ShowDialog:=True
objSession.Logoff
utils.Cleanup
Set utils = Nothing