Saving OFT with inline image

Hi,
Thanks for all your help.
I have another issue: The html images are not being embedded in the body of the email message.
Is there another switch or property that needs to be used to allow images to embed (show)?
My code is below.

Thanks again,
Kevin

MailMessage message = MailMessage.Load(strOftTemplatePath, MessageFormat.Msg);

message.Sender = new MailAddress("test@test.com");

message.To.Add(new MailAddress("test@test.com"));

message.Subject = message.Subject.Replace(“subject”, strTitle);

message.HtmlBody = message.HtmlBody.Replace(“body”, strHtmlSource);

MapiMessage msg = MapiMessage.FromMailMessage(message);

msg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);

msg.Save(strDirPath + “test.msg”);

Hi Kevin,

Sorry for the trouble you are facing.

Please have a look at the following code for your kind reference. It generates a new MailMessage and embeds a new inline image in it. It then saves the message in OFT as well MSG format. If you still find any difficulty, or have any issue in this regard, feel free to write to us.

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

// Create mail message

MailMessage message = new MailMessage();

message.Sender = new MailAddress("Sender@doamain.com", "Sender Information");

message.Subject = "This message is generated by Aspose";

message.To = new MailAddress("to@doamian.com", " Recepient one");

message.CC = new MailAddress("to@doamian.com", " Recepient Two");

// Set HTML body of message. Use image source

message.HtmlBody = "This text will appear bold" + "<br/?
Here is embeded image "
;

// Initialize linked resource for image

string strImagePath = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg";

LinkedResource image = new LinkedResource(strImagePath);

image.ContentId = "logo";

// Add image to linked resoorce

message.LinkedResources.Add(image);

//Save as OFT

message.Save("mail.oft", MailMessageSaveType.OutlookMessageFormatUnicode);

//Create MapiMessage from MailMessage

MapiMessage mapiMsg = MapiMessage.FromMailMessage(message);

//Set message flag to unsent

mapiMsg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);

//Save as MSG

mapiMsg.Save("test.msg");


Hi,

The image is now being embedded but the entire message, including the image, is rendered three times in the email (see attached image). There is also an added “<” character in the upper left-hand corner (also visible on attached image).
Plus a license text file is attached and the subject has the added text: Aspose.Email Evaluation.
I am currently using an evaluation version of the Aspose DLL.
My company is interested in purchasing the license providing the product will work properly once licensed.
We create many OFT templates manually and this would be great if I can be sure it will work.

Thanks,
Kevin

Hi Kevin,


Thank you for your interest in Aspose.Email.

Since you are using Evaluation version of Aspose.Email, it will impose certain limitations as mentioned on the Licensing page.

I would like to share with you that you can get a 30 days temporary license free of cost for testing the product completely. Please visit this LINK to get the 30 days temporary license. Once you get the license, please try your sample code with it and let us know your feedback.

Also, please share with us your code that you have used and getting the problems as you mentioned in your posting. We will try it at our end and share our findings with you.

Okay. I’ve signed up for the temporary license. Here is my order number: 121005143110
Where do I get the license and how do I apply it to the downloaded DLL?

Thanks,
Kevin

Hi Kevin,


Thanks for applying for temporary licence file. It will be soon provided by the sales support team. Its quite easy to use this licence as you don’t need to change the code and Aspose.Email for .NET dll. You just have to add following two lines of code at the start of your application.

Aspose.Email.License license = new Aspose.Email.License();

//Set the licence by providing path and name of the licence file
license.SetLicense(LicenseFileName);