简体   繁体   中英

Forward emails via C# SMTP client and keep time stamps and delivery time

I wrote a C# client to download emails from my POP3 mailbox and forward them to my internal exchange server via SMTP.

The code below is working. But the time stamps and delivery time information from the original email are overwritten hence lost because this code will create a complete new email.

Is there any chance to forward emails without loosing the time stamp information from the original email?

using (SmtpClient smtp = new SmtpClient())
{
    smtp.Connect(connectionServer["ExchangeServer"], 25);
    try
    {
        smtp.Ehlo(connectionServer["ExchangeServer"] + "." +
            connectionServer["ExchangeServerDomain"] + ".local");
    }
    catch
    {
        success = false;
        smtp.Helo(connectionServer["ExchangeServer"] + "." +
            connectionServer["ExchangeServerDomain"] + ".local");
    }
    smtp.MailFrom("");
    smtp.RcptTo(popReceipient);
    smtp.DataFromFile(path);
    smtp.Disconnect();
}

It's not possible. Another option would be to use OpenPop.Net to send a separate email with the original email attached as a "*.eml" file that can be open with most email clients. I can post some code if this approach is useful for you.

Can you access your destination server via IMAP?

If so, you can append the mail to your INBOX folder with arbitrary time stamps. If you can access your source server via IMAP, you can actually get the INTERNALDATE as well to use as the timestamp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM