1
votes

I'm new to C#. I've found how to create an outlook email from C#:

// Create a new MailItem.
Outlook._MailItem oMsg1;
oMsg1 = oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg1.To = "[email protected]";
oMsg1.Subject = "Test Subject";
oMsg1.Body = "test Body";

Outlook.Attachments oAttachs1 = oMsg1.Attachments;
// Add an attachment
string sSource1 = "C:\\testFile.xls";
Outlook.Attachment oAttach1;
oAttach1 = oAttachs1.Add(sSource1);
oMsg1.Display(true);

oApp = null;
oMsg1 = null;
oAttach1 = null;
oAttachs1 = null;

But I want to create multiple emails at the same time. So Outlook will display multiple email windows.

I tried a for loop to create multiple mailItem but this didn't work. Outlook displays only the first email.

Any idea ? Thanks!

1

1 Answers

0
votes

Use oMsg1.Display(false);

When set to True, oMsg1.Display(true) means Outlook creates a 'Modal' window, meaning it freezes that particular email until it is sent or discarded.