Getting a sent MailMessage into the “Sent Folder”

后端 未结 4 876
深忆病人
深忆病人 2021-01-01 22:02

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 addr

4条回答
  •  Happy的楠姐
    2021-01-01 22:43

    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(
            "fromaddress@blah.com", 
            "toaddress@blah.com", 
            "",
            "fromaddress@blah.com",
            "subject", 
            "body"))
    {
        var smtpClient = new SmtpClient("SmtpHost")
        {
            EnableSsl = false,
            DeliveryMethod = SmtpDeliveryMethod.Network
        };
    
        // Apply credentials
        smtpClient.Credentials = new NetworkCredential("smtpUsername", "smtpPassword");
    
        // Send
        smtpClient.Send(mailMessage);
    }
    

提交回复
热议问题