Problem in SafeMailItem.SaveAs Method

G

Guest

Hi,

I wanted to save MailItem as OFT file .

I tried the following code with redemption.dll version 3.4.0.337
it gives me warning message when I call mySafeMailItem.SaveAs method by
passing Type parameter as 'OTemplate'.

after that I used same code with redemption.dll version 3.4.0.402
because OTemplate support is added for SaveAs in redemption.dll version
3.4.0.402

it is not giving me any warning message but it saves the file as MSG
but I am passing Type parameter as 'OTemplate'.

I need help .
How can I save MailItem as OFT without warning message?

Thanks in advance

Following is the used code
--------------------------------

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim mtAtt As Attachments

Set myMail = myApp.CreateItem(olMailItem)
Set mySafeMail = CreateObject("Redemption.SafeMailItem")
mySafeMail.Item = myMail
mySafeMail.To = "(e-mail address removed)"
mySafeMail.Body = "hi this is sample mail for testing"
mySafeMail.Attachments.Add ("c:\mm.bmp")
mySafeMail.Attachments.Add ("c:\Sample.txt")
mySafeMail.SaveAs "c:\mymail.oft"

Set newMail = myApp.CreateItem(olMailItem)
Set newSafeMail = CreateObject("Redemption.SafeMailItem")
newSafeMail.Item = newMail
newSafeMail.To = "(e-mail address removed)"
newSafeMail.Attachments.Add "c:\mymail.oft"
newSafeMail.Attachments.Add "C:\Contacts.xml"

newSafeMail.Send

--------------------------------
 
D

Dmitry Streblechenko

OFT format is the same as MSG format with the sender, receiver and some
transport properties removed.

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

Guest

Hi,

Thanks for that reply.

But I want that sender,receiver name on that saved mail to use further
process.
Is there any way to save MailItem as OFT format without warning mesage

I am confuse because I used Redemption.dll and till it is giving warning
message on the following line

mySafeMailItem.SaveAs "c:\mymail.oft",oTemplate

Need your help to solve this problem

Waiting for your such kind reply

Thanks in advance again
 
D

Dmitry Streblechenko

If you need to save sender/receiver/etc properties, save in the MSG format,
not OFT.
What version of Redemption are you using? The latest version (3.4.0.402)
added the olTemplate format support.

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

Guest

Hi,

I used Redemption version 3.4.0.402 also.
With this version it is also giving warning message for following line

mySafeMail.SaveAs "C:\mymail.oft", olTemplate

and also when I used HtmlBody property of SafeMailItem

What is the problem?
I am not getting anything .
Need your help.

here is my code

------------------------------

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim mtAtt As Attachments
Dim curMailItem As MailItem
Dim oInsecptor As Inspector
Dim Str As String

Set oInsecptor = myApp.ActiveInspector
Set curMailItem = oInsecptor.CurrentItem

Set mySafeMail = oInsecptor.CurrentItem
Str = curMailItem.HTMLBody

mySafeMail.Body = Str

mySafeMail.SaveAs "C:\mymail.oft", olTemplate

Set newMail = myApp.CreateItem(olMailItem)
Set newSafeMail = CreateObject("Redemption.SafeMailItem")
newSafeMail.Item = newMail
newSafeMail.To = "(e-mail address removed)"
newSafeMail.Attachments.Add "c:\mymail.oft"
newSafeMail.Attachments.Add "C:\Documents and Settings\prasad.bhagwat\My
Documents\CodeACT7\Contacts.xml"

newSafeMail.Send
 
D

Dmitry Streblechenko

Your code (at least its first part) does not use Redemption at all. Replace
the line

Set mySafeMail = oInsecptor.CurrentItem

with

Set mySafeMail = CreateObject("Redemption.SafeMailItem")
mySafeMail.Item = oInsecptor.CurrentItem

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

Prasad Bhagwat said:
Hi,

I used Redemption version 3.4.0.402 also.
With this version it is also giving warning message for following line

mySafeMail.SaveAs "C:\mymail.oft", olTemplate

and also when I used HtmlBody property of SafeMailItem

What is the problem?
I am not getting anything .
Need your help.

here is my code

------------------------------

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim mtAtt As Attachments
Dim curMailItem As MailItem
Dim oInsecptor As Inspector
Dim Str As String

Set oInsecptor = myApp.ActiveInspector
Set curMailItem = oInsecptor.CurrentItem

Set mySafeMail = oInsecptor.CurrentItem
Str = curMailItem.HTMLBody

mySafeMail.Body = Str

mySafeMail.SaveAs "C:\mymail.oft", olTemplate

Set newMail = myApp.CreateItem(olMailItem)
Set newSafeMail = CreateObject("Redemption.SafeMailItem")
newSafeMail.Item = newMail
newSafeMail.To = "(e-mail address removed)"
newSafeMail.Attachments.Add "c:\mymail.oft"
newSafeMail.Attachments.Add "C:\Documents and Settings\prasad.bhagwat\My
Documents\CodeACT7\Contacts.xml"

newSafeMail.Send
 
G

Guest

HI,

Thanks for that change suggested.

But I used that code also.

Those lines are giving me warning messages

mySafeMail.SaveAs "C:\mymail.oft", olTemplate

and also this line

mySafeMail.Body = mySafeMail.HTMLBody

I wanted mail body as html
I also tried MailItem.BodyFormat=olFormatHTML but it is not giving me
required result.

Need help from you to solve this warning message problem
Currently I am using Redemption version 3.4.0.337

But I tried the same code with Redemption version 3.4.0.402 ,which I
downloaded from Redemptions site http://www.dimastr.com/redemption
This is Developer Version I downloaded for checking.

Following is the code used recently

---------------------------

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim mtAtt As Attachments
Dim curMailItem As MailItem
Dim oInsecptor As Inspector

Set oInsecptor = myApp.ActiveInspector
Set mySafeMail = oInsecptor.CurrentItem
mySafeMail.Body = mySafeMail.HTMLBody
mySafeMail.SaveAs "C:\mymail.oft", olTemplate


Set newMail = myApp.CreateItem(olMailItem)
Set newSafeMail = CreateObject("Redemption.SafeMailItem")
newSafeMail.Item = newMail
newSafeMail.To = "(e-mail address removed)"

newSafeMail.Attachments.Add "c:\mymail.oft"
Documents\CodeACT7\Contacts.xml"

newSafeMail.Send
 
D

Dmitry Streblechenko

Your code still does not use Redemption. Did you try to do what I suggested
in my previous post?

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim mtAtt As Attachments
Dim curMailItem As MailItem
Dim oInsecptor As Inspector

Set oInsecptor = myApp.ActiveInspector
'modified code
Set mySafeMail = CreateObject("Redemption.SafeMailItem")
mySafeMail.Item = oInsecptor.CurrentItem
'
mySafeMail.Body = mySafeMail.HTMLBody
mySafeMail.SaveAs "C:\mymail.oft", olTemplate


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

Guest

HI,

Thanks for that code.
I really missed tht code in my previous code.

I tried your suggested code with Redemption version 3.4.0.402
Now it is not giving me any warning message for any line.

But the SafeMailItem.Body is blank.
The generated mail from the code don't have any body it is absolutly blank.

How it is happening? or I am missing anything again?

following is the code

--------------------------

Dim myApp As New Outlook.Application
Dim myMail As MailItem, newMail As MailItem
Dim mySafeMail As Object, newSafeMail As Object
Dim curMailItem As MailItem
Dim oInsecptor As Inspector

Set oInsecptor = myApp.ActiveInspector
'Set curMailItem = oInsecptor.CurrentItem
' MsgBox "After set"
'Set myMail = myApp.CreateItem(olMailItem)
Set mySafeMail = CreateObject("Redemption.SafeMailItem")

mySafeMail.Item = oInsecptor.CurrentItem
mySafeMail.BodyFormat = olFormatHTML
mySafeMail.Body = mySafeMail.HTMLBody

mySafeMail.SaveAs "C:\mymail.oft", olTemplate


Set newMail = myApp.CreateItem(olMailItem)
Set newSafeMail = CreateObject("Redemption.SafeMailItem")
newSafeMail.Item = newMail
newSafeMail.To = "(e-mail address removed)"

newSafeMail.Attachments.Add "c:\mymail.oft"

newSafeMail.Send
 
G

Guest

hi,
sorry for late

I am new in outlook programming.

I don't know the use or how to use the SafeInspector object.
please guide me to achive my desired result.

thanks
waiting for your reply
 
G

Guest

HI,
Thanks for that links.

I am studing that.

But let me clear my application again.

The user creates his own mail that may be text or graphic.
This is the current mail item in Outlook.
We have our addin toolbar placed in Outlook.
When the user clicks on that toolbar button his mail get saved as a OFT
format in local harddrive.
Then we want to send this OFT file as an attchment with newly created mail
item by us programmatically.
The saved OFT formated mail contain Full HTML Body as its Body.

This is my application in short.
I am facing problem in assigning HTMLBody to Body property of the Mail Item.
Currently I am not getting any warning messages while using Redemptions
version 3.4.0.402.
But the Body of thesaved OFT formatted MailItem is empty.

I need help for this


Thanks

Waiting for your kind response

Prasad
 
D

Dmitry Streblechenko

Are you saying you are trying to assign an HTML body (HTMLBody) to teh Body
property (plain text)?
Do you save the item (MailItem.Save) before accessing the Body/HTMLBody
properties using Redemption?

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