Outlook Redemption

J

John

Hi

I am using the latest redemption. I am using the below code in vb.net to
send mail in html format. The problem is that text does not get sent as html
and html tags appear as they are in the message like '<HTML>' etc. Any idea
what I am doing wrong?

Thanks

Regards


Yahya


Imports Outlook
Imports System.Runtime.InteropServices.Marshal
Imports Redemption

Const PR_InetMailOverrideFormat = &H59020003
Const ENCODING_PREFERENCE = &H20000
Const BODY_ENCODING_TEXT_AND_HTML = &H100000
Const ENCODING_MIME = &H40000
Const PR_MSG_EDITOR_FORMAT = &H59090003
Const EDITOR_FORMAT_PLAINTEXT = 1
Const EDITOR_FORMAT_HTML = 2
Const vbLFCR = Chr(10) & Chr(13)

Dim SafeItem As Redemption.SafeMailItem
Dim oItem As Object
' Dim oItem As Outlook.MailItem
Dim Utils As Redemption.MAPIUtils
Dim ol As Outlook.Application
Dim Btn As Office.CommandBarButton
Dim ns As Outlook.NameSpace

ol = New Outlook.Application
ns = ol.GetNamespace("MAPI")
ns.Logon()
oItem = ol.CreateItem(OlItemType.olMailItem)
SafeItem = New Redemption.SafeMailItem 'Create an instance of
Redemption.SafeMailItem
SafeItem.Fields(PR_InetMailOverrideFormat) = ENCODING_PREFERENCE Or
ENCODING_MIME Or BODY_ENCODING_TEXT_AND_HTML
SafeItem.Fields(PR_MSG_EDITOR_FORMAT) = EDITOR_FORMAT_HTML
SafeItem.Item = oItem 'set Item property
oItem.To = "(e-mail address removed)"
SafeItem.Recipients.ResolveAll()
SafeItem.Subject = "Testing html in Redemption" ' <== Error: Property
Subject not supported
SafeItem.Body = "<HTML>" & vbLFCR & _
"<HEAD>" & vbLFCR & _
"<TITLE>Message</TITLE>" & vbLFCR & _
"<BODY>" & vbLFCR & _
"<p><strong>This is just a test html file to demo html
emailing.</strong></p>" & vbLFCR & _
"<p><BR>" & vbLFCR & _
"</p>" & vbLFCR & _
"</BODY>" & vbLFCR & _
"</HTML>"
SafeItem.Send()
Utils = New Redemption.MAPIUtils
Utils.DeliverNow()
Btn = ol.ActiveExplorer.CommandBars.FindControl(1, 5488)
Btn.Execute()
Utils.Cleanup()
 
J

John

Here is the definition (readonly) I can see in vs.net Object Browser of
htmlbody;

Public Overridable ReadOnly Property HTMLBody() As String
Member of: Redemption.SafeMailItem

and here is how body is defined;

Public Overridable Property Body() As String
Member of: Redemption.SafeMailItem
 
J

John

I am getting this (below) in tasklist and project does not build when using
htmlbody.

C:\...\Form1.vb(116): Property 'HTMLBody' is 'ReadOnly'.
 
J

John

Hi

A little more info. It says v3.3.0.282 on the dll properties but when I add
it into vs under COM references, the interop file (Interop.Redemption.dll)
says v3.2.

Thanks

Regards
 
S

Sue Mosher [MVP]

One approach would be to set the MailItem.HTMLBody and .Subject, then save the item and set your SafeMailItem. Then you can add the recipients.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
D

Dmitry Streblechenko

Since only reading HTMLBody property is blocked by the security patch,
that's what Redemption implements. Setting the property does not cause the
security popup, so you can set it on the original OOM object assigned to the
Item property. Or define SafeMailItem as a generic Object to avoid the
compiler errors, at run-time Redenption will forward all calls to the
properties and methods that it does not implement to the object assigned to
the Item property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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