How to open the new Outlook to send en email with attachments?

Wambo 5 Reputation points
2024-04-30T17:15:16.43+00:00

Hello,

I would like to know how to open the new Outlook mail to send an email with attachments in c#.

I tried generating an .eml file and open it in the new outlook but the new Outlook does not support the X-Unsent: 1 flag. So the email does open, but you cannot send it.

Thanks

Outlook
Outlook
A family of Microsoft email and calendar products.
3,815 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,906 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Jiachen Li-MSFT 31,166 Reputation points Microsoft Vendor
    2024-05-01T01:53:26.3966667+00:00

    Hi @Wambo ,

    You can use Microsoft.Office.Interop.Outlook Namespace.

    Check the following code.

    
    using Outlook = Microsoft.Office.Interop.Outlook;
    
                Outlook.Application outlookApp = new Outlook.Application();
    
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
    
                mailItem.To = "recipient@example.com";
    
                mailItem.Subject = "Test Email";
    
                mailItem.Body = "This is a test email.";
    
                mailItem.Attachments.Add(@"C:\Path\To\File1.txt");
    
                mailItem.Send();
    
    
    

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Bruce (SqlWork.com) 64,901 Reputation points
    2024-08-28T22:22:37.28+00:00

    the new outlook (Monarch), does not support automation and only has limited support of .msg and .eml files. you should use the graph api to access the email system. you can use the mailto cmd to create an email, but it does not support attachments:

    var proc = new System.Diagnostics.Process();
    proc.StartInfo.FileName = "mailto:someone@somewhere.com?subject=hello&body=some text";
    proc.Start();
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.