Create email in c# using Mailkit and send later in Outlook ActiveSync

172 views Asked by At

I am currently creating emails with Mailkit in c# and I append it to an own folder. When I try to send the email from the server or in Outlook with IMAP or Exchange connector, it works fine. But when I try to send the email with Outlook ActiveSync, the send button is missing and I cannot find a way to send the message. Do you have any idea?

using (var client = new ImapClient())
{
    String email = "";
    String password = "";
    String server = "";
    
    client.Connect(server, 993, true);
    client.Authenticate(email, password);
    
    var inbox = client.GetFolder(client.PersonalNamespaces[0]);
    var testfolder = inbox.Create("Testfolder", true);
    
    var reply = new MimeMessage();
    reply.From.Add(new MailboxAddress("Test", email));
    reply.To.Add(new MailboxAddress("Test", ""));
    reply.Subject = "Testemail";
    
    var bodyBuilder = new BodyBuilder();
    bodyBuilder.HtmlBody = "";
    reply.Body = bodyBuilder.ToMessageBody();

    testfolder.Append(reply, MessageFlags.Draft);
    
    client.Disconnect(true);
}

I would expect the send button as in Outlook with Exchange connector: Send Button available

But an email is created in the folder that I am unable to send: No send Button available

1

There are 1 answers

7
Dmitry Streblechenko On

That is because Outlook treats your message as sent. Make sure to add X-Unsent: 1 MIME header.