通过附件发送.Net发送的电子邮件 [英] Send a email from .Net with attachment
问题描述
您好我想从c#发送邮件。在gmail中,我使用SMTP成功发送了邮件。但现在我想使用POP3发送到服务器。
我尝试了下面的代码。但是我在POP3名称空间中出错了。
任何人帮我做这个。
POP3class pop3;
pop3 = new POP3class();
pop3.DoConnect(your.mail.server,110,username,password);
pop3.GetStat ();
MessageClass消息;
msg = new MessageClass();
string sMessageTop = msg。 GetTop(1);
string sAllMessage = msg.Retr(1);
msg.GetBody(sAllMessage);
POP3用于检索和删除邮件,而不是用于发送。至于POP3命名空间中的问题,您没有提供任何信息。我会说,命名空间通常与任何问题无关。
-SA
MailMessage mail = new MailMessage();
mail.From =tes@server.com.au;
mail.To =tes @ server.com.au;
mail.Subject =日志文件;
mail.Body =DataLoad details;
System.Web.Mail.MailAttachment附件;
附件= new System.Web.Mail.MailAttachment(Log_file +\\log_+ DateTime.Now.Date.ToString(dd-MM-yyyy)+。txt);
mail.Attachments.Add(附件);
SmtpMail.SmtpServer =mail.test.com.au;
SmtpMail.Sen d(邮件);
Hi I want to send the mail from c#. In gmail i sucessfully sent the mail by using SMTP. But now i want to send to server using POP3.
I tried the below code. But i got error in POP3 namespace.
Any one help me to do this.
POP3class pop3;
pop3 = new POP3class();
pop3.DoConnect("your.mail.server", 110, "username", "password");
pop3.GetStat();
MessageClass msg;
msg = new MessageClass();
string sMessageTop = msg.GetTop(1);
string sAllMessage = msg.Retr(1);
msg.GetBody(sAllMessage);
POP3 is for retrieving and deleting mail, not for sending. As to the "problem in POP3 namespace", you did not provide any information. I would say, namespaces are generally irrelevant to any problems.
—SA
MailMessage mail = new MailMessage();
mail.From = "tes@server.com.au";
mail.To = "tes@server.com.au";
mail.Subject = "Log file" ;
mail.Body = "DataLoad details";
System.Web.Mail.MailAttachment attachment;
attachment = new System.Web.Mail.MailAttachment(Log_file + "\\log_" + DateTime.Now.Date.ToString("dd-MM-yyyy") + ".txt");
mail.Attachments.Add(attachment);
SmtpMail.SmtpServer = "mail.test.com.au";
SmtpMail.Send(mail);
这篇关于通过附件发送.Net发送的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!