mistique
mistique

Reputation: 111

Outlook window blocks access to Windows.Forms

I have Windows.Forms application from which i need to open Outlook and programmatically fill address and subject. After this:

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook._MailItem oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMailItem.To = sto;
oMailItem.Subject = sid;
oMailItem.Display(true);

Outlook blocks access to the Windows.Forms application. But I need to copy some data from Windows.Forms app manually to the email body. I can't find good solution. I'd appreciate any help.

Upvotes: 1

Views: 289

Answers (2)

Bolu
Bolu

Reputation: 8786

need to use: oMailItem.Display();

Display(Modal): True to make the window modal. The default value is False.

REF:MailItem.Display Method

Upvotes: 2

Charbel
Charbel

Reputation: 658

Change your last line to:

oMailItem.Display(false);

The modal argument means that the form will be blocked by the mail window

Upvotes: 3

Related Questions