views:

173

answers:

2

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?

+1  A: 

You need to send the message from Outlook if you want to have the sent message in the "Sent messages" folder. This folder is an Outlook (and many other mail clients) concept, not an SMTP concept.

You can use the Outlook Automation API to ask Outlook to create an e-mail and send it.

Timores
+3  A: 

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);
}
RSolberg
Thanks for your response! That's definitely a likely consideration now as it's literally just confirmation I need...
Robert Reid