Redemption - Outlook

  • Thread starter Thread starter Terry
  • Start date Start date
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
 
Outlook version? That's a critical factor related to the options for
creating a plain text message.
 
Hello Sue,

I need to be able to produce plain text messages in A97 and A2K. I am
currently testing using A2K.

Regards

Terry
 
A97? A2K? You mean Outlook 97 and Outlook 2000?

In both cases, the only direct way to create a plain-text message in those
versions is to use CDO, not Outlook, to initially create the message using
the CDO Message object and set its Text property. Once you create and save
the message, you should be able to get it as an Outlook item, using
Namespace.GetItemFromID, then set the SafeMailItem.Item property to that
Outlook item to finish the job.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
After the line
Set objOutlook = CreateObject("Outlook.Application")
add
set objNS = objOutlook.GetNamespace("MAPI")
objNS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Hello Dmitry,
Thanks for the help, the first test message after the change was sent and
received sucessfully. The received message was in plain text.

Just one question, as I had not specified a body format can I assume that
the format is what I have already setup in Outlook's options? i.e. plain
text

Regards

Terry
 
Hi Sue,
Thanks for the advice. It is now obvious to me that I need to have a look
CDO/MAPI for further development. I have had a look at your site and will
try and get a copy of the book in the UK along with other source material.
Regards
Terry
 
when I put this code in "after update" I get the error "Active
componet cannot create object" Any suggestions
 
What code? Where? Please take the time to quote the original message
manually so that people reading your current response can understand what
you're talking about. Otherwise, you may not receive the answer you're
looking for.
 
Back
Top