Set e-mail Plain Text programmatically

Add-in Express™ Support Service
That's what is more important than anything else

Set e-mail Plain Text programmatically
 
Matteo Pasqualin




Posts: 27
Joined: 2006-08-04
Hy Sergey,

I'd like to set the Body of the e-mail as Plain Text when the user select a specific option from a combo in my InspectorCommandBar.

The problem is that with the following code, I managed to modify the combo of the current e-mail in wich people can set the type of text, but not the body of the e-mail, moreover the HTML bar remains active even if I modified the combo in Plain Text. Where am I wrong?

Here is my code:

private void adxCmdBarCombo_ifNotify_Change(object sender)
{
if (this.olInsp.CurrentItem is Microsoft.Office.Interop.Outlook.MailItem)
{
Outlook.MailItem _mailItem = null;

if (string.CompareOrdinal(adxCmdBarCombo_ifNotify.Text, "Notify Subject and Body") == 0)
{
try
{
this._olSecurityManager.DisableOOMWarnings = true;

_mailItem = (Outlook.MailItem)this.olInsp.CurrentItem;

MessageBox.Show("E-Mail text will be set to plain text");

_mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain;
}
catch (Exception ex)
{
...
}

}

...

Thanx

Matteo Pasqualin
Posted 20 Nov, 2006 11:33:36 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Matteo.

Please try the code below:

.......
_mailItem = (Outlook.MailItem)this.olInsp.CurrentItem;
string body = _mailItem.Body;
_mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain;
_mailItem.Body = body;
_mailItem.Save();
......

P.S. Note that we take up your forum requests in the order we receive them. Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 20 Nov, 2006 13:35:46 Top
Matteo Pasqualin




Posts: 27
Joined: 2006-08-04
Hi Sergey,

great, it works fine!

Matteo
Posted 21 Nov, 2006 02:39:22 Top