Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook email message UI looks different when created through .NET API

Status
Not open for further replies.

dalchri

Programmer
Apr 19, 2002
608
US
When I create a new email message using the Outlook XP .NET API, it looks different than when it is created through the UI of Outlook itself.

For example, when creating a new email message, the To and CC buttons are flat and have the picture of the address book next to them.

When creating the email message through the .NET API, the new email message has the old 3D style To and CC buttons.

Other differences include different placement and availability of toolbar buttons which is confusing my users. Anyone know if there is something I can do to create an email message exactly the same way that Outlook does?

Code:
Microsoft.Office.Interop.Outlook.MailItem msg = (Microsoft.Office.Interop.Outlook.MailItem) 
				new Microsoft.Office.Interop.Outlook.ApplicationClass().CreateItem(
				Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

//Create a new email message
msg.To = strTo;
msg.Subject = strSubject;
msg.Body = strBody;
//strAttachment is the filename of a PDF file created elsewhere
msg.Attachments.Add(strAttachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1, "");

if (blnPrompt) {
	//Display the new email message modally so the user can modify it
	msg.Display(true);
} else {
	msg.Send();
}
 
Well, this is arcane but apparently this line of code resolves the problem:

Code:
//For some reason the default editor does not match what you get in Outlook using the UI
//unless you simply call this property
//This must be called before the Display method
object objDummy = msg.GetInspector;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top