T
Terry
I am trialing Redemption to circumvent Outlooks security nags. I have
included my test code below which is run from MS Access VBA.
A message is generated but appears in the Outlook Inbox, without a From
name, in RTF format and flagged by Outlook as not sent.
I need to send the message with the correct from address, in plain text and
have it appear in the Outbox to send, or in the Sent folder if it has
already been sent.
Any help please?
Regards
Terry
Acknowledgments and thanks to
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
*** Test Code***
Public Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim SafeItem
Set SafeItem = CreateObject("Redemption.SafeMailItem")
' create the Outlook session
Set objOutlook = CreateObject("Outlook.Application")
' create the Message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
SafeItem.Item = objOutlookMsg
With SafeItem
.Recipients.Add "MyRecipient<[email protected]>"
.Subject = "Testing"
.Body = "This is a test of Redemption"
'.Display
.Save
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlookMsg = Nothing
Set SafeItem = Nothing
End Sub
***Above code to replace what follows***
Public Sub SendMessage_old(DisplayMsg As Boolean, 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 recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' add the CC recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olCC
' add the BCC recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olBCC
' set the Subject, Body and Importance of the mesage
.Subject = "This is an automation test with outlook"
.Body = "This is the body of the message"
.Importance = olImportanceHigh ' high importance
' add attachments to the message
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' resolve each recipients name
'For Each objOutlookRecip In .Recipients
' objOutlookRecip.Resolve
'Next
' should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
included my test code below which is run from MS Access VBA.
A message is generated but appears in the Outlook Inbox, without a From
name, in RTF format and flagged by Outlook as not sent.
I need to send the message with the correct from address, in plain text and
have it appear in the Outbox to send, or in the Sent folder if it has
already been sent.
Any help please?
Regards
Terry
Acknowledgments and thanks to
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
*** Test Code***
Public Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim SafeItem
Set SafeItem = CreateObject("Redemption.SafeMailItem")
' create the Outlook session
Set objOutlook = CreateObject("Outlook.Application")
' create the Message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
SafeItem.Item = objOutlookMsg
With SafeItem
.Recipients.Add "MyRecipient<[email protected]>"
.Subject = "Testing"
.Body = "This is a test of Redemption"
'.Display
.Save
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlookMsg = Nothing
Set SafeItem = Nothing
End Sub
***Above code to replace what follows***
Public Sub SendMessage_old(DisplayMsg As Boolean, 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 recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' add the CC recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olCC
' add the BCC recipients to the message
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olBCC
' set the Subject, Body and Importance of the mesage
.Subject = "This is an automation test with outlook"
.Body = "This is the body of the message"
.Importance = olImportanceHigh ' high importance
' add attachments to the message
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' resolve each recipients name
'For Each objOutlookRecip In .Recipients
' objOutlookRecip.Resolve
'Next
' should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub