Search code examples
c#smtpclientexchange-servermailmessage

Getting a sent MailMessage into the "Sent Folder"


I'm sending MailMessages with an SmtpClient (being delivered successfully) using an Exchange Server but would like my sent emails to go to the Sent Folder of the email address I'm sending them from (not happening).

using (var mailMessage = new MailMessage("[email protected]", "[email protected]", "subject", "body"))
{
    var smtpClient = new SmtpClient("SmtpHost")
    {
        EnableSsl = false,
        DeliveryMethod = SmtpDeliveryMethod.Network
    };

    // Apply credentials
    smtpClient.Credentials = new NetworkCredential("smtpUsername", "smtpPassword");

    // Send
    smtpClient.Send(mailMessage);
}

Is there a configuration I'm missing that will ensure all of my sent emails from "[email protected]" arrive in their Sent Folder?


Solution

  • I'm guessing that your requirement is mainly oriented around giving the users visibility to what emails have been sent. The sent items folder would be one method to allow this to occur. In the past, I've solved this problem by adding a BCC Address that would literally send the email directly to either a distribution list, user, or shared mailbox that allowed the users to review what had been sent.

    Try this with an outlook rule of some kind to move the item to their sent items folder marked as read...

    using (var mailMessage = new MailMessage(
            "[email protected]", 
            "[email protected]", 
            "",
            "[email protected]",
            "subject", 
            "body"))
    {
        var smtpClient = new SmtpClient("SmtpHost")
        {
            EnableSsl = false,
            DeliveryMethod = SmtpDeliveryMethod.Network
        };
    
        // Apply credentials
        smtpClient.Credentials = new NetworkCredential("smtpUsername", "smtpPassword");
    
        // Send
        smtpClient.Send(mailMessage);
    }