How to send mail from Visual Basic .Net Windows App

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mashraf

    #1

    How to send mail from Visual Basic .Net Windows App

    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

  • Mark D. Richter

    #2
    Re: How to send mail from Visual Basic .Net Windows App

    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.SmtpSe rver = "smtp.foo.n et";
    MailMessage mail = new MailMessage();
    mail.To = "help@foosoft.c om";
    mail.From = custEmail.Text;
    mail.Subject = "Request";
    mail.Body = custName.Text + "\n\n" + custPhone.Text + "\n\n" +
    custDescription .Text;

    SmtpMail.Send(m ail);



    mashraf wrote:
    [color=blue]
    > 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
    >[/color]

    Comment

    • Mark D. Richter

      #3
      Re: How to send mail from Visual Basic .Net Windows App

      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.SmtpSe rver = "smtp.foo.n et";
      MailMessage mail = new MailMessage();
      mail.To = "help@foosoft.c om";
      mail.From = custEmail.Text;
      mail.Subject = "Request";
      mail.Body = custName.Text + "\n\n" + custPhone.Text + "\n\n" +
      custDescription .Text;

      SmtpMail.Send(m ail);



      mashraf wrote:
      [color=blue]
      > 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
      >[/color]

      Comment

      • Guest's Avatar

        #4
        Re: How to send mail from Visual Basic .Net Windows App

        Thanks Mark,
        I did not refrence the mail class. Your code snipet worked
        fine. Thanks again.
        Mashraf
        [color=blue]
        >-----Original Message-----
        >Mahsraf,
        >
        >You need to include System.Web.Mail . Then you can create[/color]
        and populate a[color=blue]
        >MailMessage object and send it using the system[/color]
        SmtpServer object.[color=blue]
        >Here's a C# code snippet of mine. The VB is quite similar.
        >
        >--mark richter
        >
        > using System.Web.Mail ;
        >..
        >..
        >..
        > SmtpMail.SmtpSe rver = "smtp.foo.n et";
        > MailMessage mail = new MailMessage();
        > mail.To = "help@foosoft.c om";
        > mail.From = custEmail.Text;
        > mail.Subject = "Request";
        > mail.Body = custName.Text + "\n\n" +[/color]
        custPhone.Text + "\n\n" +[color=blue]
        >custDescriptio n.Text;
        >
        > SmtpMail.Send(m ail);
        >
        >
        >
        >mashraf wrote:
        >[color=green]
        >> Hi,
        >> I am trying to send Mail from VB.net app but I can not[/color][/color]
        do[color=blue][color=green]
        >> it. Even I can not do this = Imports system.mail, the[/color][/color]
        mail[color=blue][color=green]
        >> option is not available. I also have to do more then[/color][/color]
        one[color=blue][color=green]
        >> atachements. Some one please help.
        >>
        >> Thanks,
        >> mashraf
        >>[/color]
        >
        >.
        >[/color]

        Comment

        Working...