protected void SendSuccess()
{
SystemNetMailMailMessage message = new SystemNetMailMailMessage();
messageFrom = new MailAddress("test@gmailcom", "someone");//必须是提供smtp服务的邮件服务器
messageToAdd(new MailAddress("test@yahoocomcn"));
messageSubject = "测试邮件" ;
messageCCAdd(new MailAddress("test@126com"));
messageBccAdd(new MailAddress("test@126com"));
messageIsBodyHtml = true;
messageBodyEncoding = SystemTextEncodingUTF8;
messageBody = "邮件发送测试";
messagePriority = SystemNetMailMailPriorityHigh;
SmtpClient client = new SmtpClient("smtpgmailcom", 587); // 587;//Gmail使用的端口
clientCredentials = new SystemNetNetworkCredential("test@gmailcom", "password"); //这里是申请的邮箱和密码
clientEnableSsl = true; //必须经过ssl加密
try
{
clientSend(message);
ResponseWrite("邮件已经成功发送到" + messageToToString() + "<br>");
}
catch (Exception ee)
{
ResponseWrite(eeMessage + "<br>" / + eeInnerExceptionMessage/ );
}
}
收邮件
using LumiSoftNetPOP3Client;
using LumiSoftNetMail;
……
public IList<Mail_Message> ReceiveMail()
{
IList<Mail_Message> mailList = new List<Mail_Message>();
using (POP3_Client client = new POP3_Client())
{
clientConnect("popgmailcom",995,true);
clientAuthenticate("zwseaman", "zw_seaman", false);
POP3_ClientMessageCollection coll = clientMessages;
for (int i = 0; i < collCount; i++)
{
POP3_ClientMessage message = coll[i];
Mail_Message mm = Mail_MessageParseFromByte(coll[i]MessageToByte());
mailListAdd(mm);
}
}
return mailList;
}
protected void Page_Load(object sender, EventArgs e)
{
IList<Mail_Message> mailList = new ZMailMail()ReceiveMail();
foreach (Mail_Message mail in mailList)
{
StringBuilder sb = new StringBuilder();
sbAppend(mailFromToString())Append(" 发送给 ");
sbAppend(mailToToString())Append("<br/>") ;
sbAppend(mailSubject)Append("<br/>");
sbAppend(mailBodyHtmlText)Append("<hr/>");
ResponseWrite(sbToString());
}
}
你可以用smtp协议来发送邮件
用pop3来接收邮件
具体发送的代码全是api函数,直接调用就行了
想加界面的话用c++的mfc或者调用api建窗口
百度搜都有的
用我这个,根据发件邮箱,更改下面的服务器,原邮箱,目的邮箱,然后将程序快捷方式放在启动里就可实现开机运行,不要做非法的事
Private Sub Form_Load()
MeVisible = False
Dim objEmail As Object
Set objEmail = CreateObject("CDOMessage")
objEmailFrom = "原邮箱"
objEmailTo = "目的邮箱"
objEmailSubject = "邮件标题"
objEmailTextbody = "邮件正文 "
objEmailAddAttachment AppPath & "\abcini" '附件内容,不要可删掉
objEmailConfigurationFieldsItem(">
以上就是关于用C#编写一个收发邮件的小程序,求代码和原理简单讲解全部的内容,包括:用C#编写一个收发邮件的小程序,求代码和原理简单讲解、用C语言写一个邮件收发程序,不知道该怎么做!求大神指导!、如何编写自动发邮件的程序。用VB编写,开机自动后台运行,并发送邮件到指定邮箱。等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)