Creating and Sending an Email through "New Outlook" from a Desktop Application

Selim Basyouni 15 Reputation points
2024-04-02T08:48:52.8366667+00:00

Hello everyone,

Previously, we have been creating emails through our desktop applications, which can be edited and sent using various email programs. These emails, along with the recipients, subject, content, and attachments, are pre-formulated within our programs, and then the user can proceed to edit and send them.

However, as the "New Outlook" no longer supports, nor will it continue to support, the COM-Interop interface, we are currently looking for an alternative. Creating .msg or .eml files is not an option, as these cannot be edited or sent using "New Outlook".

Would anyone be able to advise a method for programmatically creating an email that can be edited and sent through Outlook?

Best regards,

Selim Basyouni

Outlook
Outlook
A family of Microsoft email and calendar products.
3,903 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,937 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Selim Basyouni 15 Reputation points
    2024-07-24T09:59:07.26+00:00

    Hello @mixxxel and everyone facing the same problem,

    Luckily i found a solution for this issue. Using .Net, you can easily create eml. Files. Adding 'X-Unsent: 1' to the first line will make 'The New Outlook' to open that mail as draft, allowing you to edit and send the Mail.

    Best regards
    Selim Basyouni

    Example C# Code:

    // Erstellen einer neuen E-Mail-Nachricht
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("sender@example.com");
    mail.To.Add("test@example.de");
    mail.Subject = "Test";
    mail.Body = "Das ist eine Test eMail.";
    // Speichern der E-Mail in einer .eml-Datei
    string emlFilePath = "mail.eml";
    using (var ms = new MemoryStream())
    using (var smtpClient = new SmtpClient())
    
    
    1 person found this answer helpful.

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.