Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted

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
 
Share this answer
 
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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900