How to send mail from Visual Basic .Net Windows App

  • Thread starter Thread starter mashraf
  • Start date Start date
M

mashraf

Hi,
I am trying to send Mail from VB.net app but I can not do
it. Even I can not do this = Imports system.mail, the mail
option is not available. I also have to do more then one
atachements. Some one please help.

Thanks,
mashraf
 
Mahsraf,

You need to include System.Web.Mail. Then you can create and populate a
MailMessage object and send it using the system SmtpServer object.
Here's a C# code snippet of mine. The VB is quite similar.

--mark richter

using System.Web.Mail;
..
..
..
SmtpMail.SmtpServer = "smtp.foo.net";
MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = custEmail.Text;
mail.Subject = "Request";
mail.Body = custName.Text + "\n\n" + custPhone.Text + "\n\n" +
custDescription.Text;

SmtpMail.Send(mail);
 
Mahsraf,

You need to include System.Web.Mail. Then you can create and populate a
MailMessage object and send it using the system SmtpServer object.
Here's a C# code snippet of mine. The VB is quite similar.

--mark richter

using System.Web.Mail;
..
..
..
SmtpMail.SmtpServer = "smtp.foo.net";
MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = custEmail.Text;
mail.Subject = "Request";
mail.Body = custName.Text + "\n\n" + custPhone.Text + "\n\n" +
custDescription.Text;

SmtpMail.Send(mail);
 
Thanks Mark,
I did not refrence the mail class. Your code snipet worked
fine. Thanks again.
Mashraf
 
Back
Top