Dev*_*avi 5 c# asp.net email openpop
我开发了一个Web应用程序,其中有一个功能可以为特定的销售订单输入注释.
当客户或客户服务主管输入注释时,会向相关方发送电子邮件通知(使用C#中的SmtpClient和MailMessage对象发送电子邮件通知).
using (MailMessage objEmail = new MailMessage())
{
Guid objGuid = new Guid();
objGuid = Guid.NewGuid();
String MessageID = "<" + objGuid.ToString() + ">";
objEmail.Body = messagebody.ToString();
objEmail.From = new MailAddress(sFrmadd, sFrmname);
objEmail.Headers.Add("Message-Id", MessageID);
objEmail.IsBodyHtml = true;
objEmail.ReplyTo = new MailAddress("replyto@email.com");
objEmail.Subject = sSubject;
objEmail.To.Add(new MailAddress(sToadd));
SmtpClient objSmtp = new SmtpClient();
objSmtp.Credentials = new NetworkCredential("mynetworkcredential", "mypassword");
objSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtp.EnableSsl = true;
objSmtp.Host = "myhostname";
objSmtp.Port = 25;
objSmtp.Timeout = 3 * 3600;
objSmtp.Send(objEmail);
}
Run Code Online (Sandbox Code Playgroud)
我设置Guid为Message-Id邮件的邮件头发送.
这一切都很好.
现在,我想开发一种功能,供各方回复各自收件箱中的电子邮件通知.
我想在同一Sales -Order的注释中记录回复(该方收到通知).
我正在使用OpenPop.dll来读取收件箱中的通知回复.
/// <summary>
/// Fetch all messages from a POP3 server
/// </summary>
/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
/// <param name="useSsl">Whether or not to use SSL to connect to server</param>
/// <param name="username">Username of the user on the server</param>
/// <param name="password">Password of the user on the server</param>
/// <returns>All Messages on the POP3 server</returns>
public static List<Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<Message> allMessages = new List<Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
for (int i = 1; i <= messageCount; i++)
{
allMessages.Add(client.GetMessage(i));
}
// Now return the fetched messages
return allMessages;
}
}
Run Code Online (Sandbox Code Playgroud)
从上面的功能,我可以阅读我的"replyto@email.com"帐户的所有电子邮件.但我无法在电子邮件Message-Id的In-reply-to标题中找到.
我不知道我做错了什么.
我能想到的最佳解决方案是使用例如“+”号将您的数据放在“发件人”和/或“回复”标题中。
假设您的退货地址是 replies@yourdomain.com
您必须在邮件服务器中添加过滤规则,以便任何发送到回复+任何相关数据here@yourdomain.com 的邮件都落入回复@yourdomain.com 邮箱
Facebook 通知将此用于直接电子邮件回复。
gmail 也使用它(如果您有 gmail 地址,请尝试使用)
(见http://forums.smartertools.com/showthread.php/27790-Plus-Addressing-configure-symbol)
希望这会有所帮助。如果是这样,祝你邮件服务器配置好运
| 归档时间: |
|
| 查看次数: |
3758 次 |
| 最近记录: |