sending mail

lude8880 2008-12-08 10:28:37
我自己搭了一个email server,里面的地址只能自己互相传,怎么用c#编一个程序,让一个用户收到mail后自动转发给真实的mailadress啊
...全文
112 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tiger_ldy 2008-12-08
  • 打赏
  • 举报
回复
学习了啊
j45kp 2008-12-08
  • 打赏
  • 举报
回复
public class SipMail
{
private static CDO.MessageClass mailExchange;

private static CDO.MessageClass MailExchange
{
get
{
if (null == mailExchange)
{
mailExchange = new CDO.MessageClass();
ADODB.Fields oFields = mailExchange.Configuration.Fields;

oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendmailaddress"].Value = "sip@asus.com.tw";//mail from
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value = "smtp@csc.asus.com.tw";
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = "smtp"; //mail server account
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = "asus0302"; //mail server password
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value = 0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "csc.asus.com.tw"; //mail server"192.168.88.15"

mailExchange.From = "SIP<sip@asus.com.tw>";
}
return mailExchange;
}
}

public SipMail()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

public static bool SendMail(string receiver, string subject, string content)
{
bool result = true;

try
{
MailExchange.To = receiver;
MailExchange.Subject = subject;
MailExchange.HTMLBody = content;

MailExchange.Configuration.Fields.Update();
mailExchange.HTMLBodyPart.Charset = "unicode-1-1-utf-8";
mailExchange.TextBodyPart.Charset = "unicode-1-1-utf-8";
MailExchange.Send();
}
catch
{
result = false;
}
finally
{
}
return result;
}
}

SipMail.SendMail("xxx@sina.com", "标题“,内容);
Red_Stone 2008-12-08
  • 打赏
  • 举报
回复
调用email server的接口就可以了啊。
hawaiiboys 2008-12-08
  • 打赏
  • 举报
回复
顶下

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧