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,096 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,364 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 27,001 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.