3

I have a programme where it opens new outlook email window with pre-populated to, cc, title and body. Code is follow this Programmatically Create an E-Mail Item.

This been working fine for few years and recently it started having some issue with some users, when the new email window opened To, Send fields are seems to be overlapping (as below)

enter image description here

Anyone have idea why its doing this?

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
  • 1
    I don't think this has anything to do with the code. I guess something went wrong with your current outlook installation. Repairing office installation might help. – Bikswan Jan 03 '18 at 19:23
  • If the problem occured with some users, it might be a [problem with their outlook profiles](https://partnersupport.microsoft.com/en-us/par_clientsol/forum/par_outlook/outlook-2013-content-overlap/0ff967ff-10e7-45ba-ae94-0d53032eeaf3?auth=1). Try to delete and recreate them. Another option is to [open Office application with save mode](https://support.office.com/en-us/article/Open-Office-apps-in-safe-mode-on-a-Windows-PC-dedf944a-5f4b-4afb-a453-528af4f7ac72?CTT=1&CorrelationId=e021c891-1a71-4d38-a9a7-22285d019281&ui=en-US&rs=en-US&ad=US&ocmsassetID=HP010354300). – Maciej Los Jan 03 '18 at 19:40

2 Answers2

0

Your Outlook installation may be defective, or I it may be caused by your display's settings and the fact that Outlook can't handle the scaling setting.

If the app looks normal when opened manually from the exe file, the problem is probably in the Office.Interop API itself.

Process.Start approach

You could create the mail message via command-line parameters and run the process itself:

System.Diagnostics.Process.Start(
   "C:\\Program Files (x86)\\Microsoft Office\\Office15\\OUTLOOK.EXE", 
    "/c ipm.note /m hello@example.com"));

Where Office15 would be the version of your Office installation. Unfortunately this approach doesn't enable you to add the other fields like CC, etc.

mailto: approach

A great alternative could be to use the mailto: protocol, because it doesn't require the user to have Outlook installed and will work with any e-mail client and it still covers all your needs. To use it you construct the mailto: URI like:

var mailtoUri = "mailto:someone@example.com?subject=This%20is%20the%20subject&cc=someone_else@example.com&body=This%20is%20the%20body"

And then you launch that URI to open the user's default assigned mail client:

var startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.FileName = mailtoUri;
Process.Start(startInfo);

More details on the mailto: protocol are available on MSDN.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91