System.Web.Mail namespace?

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

    System.Web.Mail namespace?

    Hello, I'm trying to create a basic SMTP mail sender using that code,
    i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
    (system.web.MAI L)

    I'm only allowed to declare under that namespaces with "system.web ":

    System.Wb.AspNe tHostingPermiss ion
    System.Web.AspN etHostingPermis sionAttribute
    System.Web.AspN etHostingPermis sionLevel


    Imports System.Web.mail
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles Button1.Click

    Try
    Dim insMail As New System.()
    With insMail
    .From = "omar.abid2006@ gmail.com"
    .To = "omar.abid2006@ gmail.com"
    .Subject = "test"
    .Body = "test sending email"
    End With
    SmtpMail.SmtpSe rver = "your smtp server"
    SmtpMail.Send(i nsMail)
    Console.WriteLi ne("Successfull y sent email message" +
    vbCrLf)
    Catch err As Exception
    MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
    "Error")
    End Try
    End Sub


    However, is there a limitation for "express" version or is there
    something wrong about coding?

    Thanks...

  • Spam Catcher

    #2
    Re: System.Web.Mail namespace?

    kimiraikkonen <kimiraikkonen8 5@gmail.comwrot e in
    news:1192825563 .391463.36070@k 35g2000prh.goog legroups.com:
    Imports System.Web.mail
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
    As System.EventArg s) Handles Button1.Click
    >
    Try
    Dim insMail As New System.()
    With insMail
    .From = "omar.abid2006@ gmail.com"
    .To = "omar.abid2006@ gmail.com"
    .Subject = "test"
    .Body = "test sending email"
    End With
    SmtpMail.SmtpSe rver = "your smtp server"
    SmtpMail.Send(i nsMail)
    Console.WriteLi ne("Successfull y sent email message" +
    vbCrLf)
    Catch err As Exception
    MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
    "Error")
    End Try
    End Sub
    >
    >
    However, is there a limitation for "express" version or is there
    something wrong about coding?
    What problem are you having?

    Are you having trouble connecting to your SMTP server?

    Comment

    • kimiraikkonen

      #3
      Re: System.Web.Mail namespace?

      On Oct 19, 11:30 pm, Spam Catcher <spamhoney...@r ogers.comwrote:
      kimiraikkonen <kimiraikkone.. .@gmail.comwrot e innews:11928255 63.391463.36070 @k35g2000prh.go oglegroups.com:
      >
      >
      >
      Imports System.Web.mail
      Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
      As System.EventArg s) Handles Button1.Click
      >
      Try
      Dim insMail As New System.()
      With insMail
      .From = "omar.abid2...@ gmail.com"
      .To = "omar.abid2...@ gmail.com"
      .Subject = "test"
      .Body = "test sending email"
      End With
      SmtpMail.SmtpSe rver = "your smtp server"
      SmtpMail.Send(i nsMail)
      Console.WriteLi ne("Successfull y sent email message" +
      vbCrLf)
      Catch err As Exception
      MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
      "Error")
      End Try
      End Sub
      >
      However, is there a limitation for "express" version or is there
      something wrong about coding?
      >
      What problem are you having?
      >
      Are you having trouble connecting to your SMTP server?
      No, i get some error messages from Vb.net 2005 "express" starting with
      "'Imports' statements must precede any declarations" continues with
      other errors about declerations (e.g.insmail, smtpmail) as well.

      Sorry for being beginner.

      thanks...

      Comment

      • Spam Catcher

        #4
        Re: System.Web.Mail namespace?

        kimiraikkonen <kimiraikkonen8 5@gmail.comwrot e in
        news:1192826261 .535602.123970@ z24g2000prh.goo glegroups.com:
        No, i get some error messages from Vb.net 2005 "express" starting with
        "'Imports' statements must precede any declarations" continues with
        other errors about declerations (e.g.insmail, smtpmail) as well.
        >
        Sorry for being beginner.
        >
        thanks...
        Imports should go at the very top of your class file.

        Imports System.Web.Mail


        Public Class....


        Your Function Here

        End Class

        Comment

        • Rad [Visual C# MVP]

          #5
          Re: System.Web.Mail namespace?

          On Fri, 19 Oct 2007 13:26:03 -0700, kimiraikkonen
          <kimiraikkonen8 5@gmail.comwrot e:
          >Hello, I'm trying to create a basic SMTP mail sender using that code,
          >i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
          >(system.web.MA IL)
          >
          >I'm only allowed to declare under that namespaces with "system.web ":
          >
          >System.Wb.AspN etHostingPermis sion
          >System.Web.Asp NetHostingPermi ssionAttribute
          >System.Web.Asp NetHostingPermi ssionLevel
          >
          >
          >Imports System.Web.mail
          Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
          >As System.EventArg s) Handles Button1.Click
          >
          Try
          Dim insMail As New System.()
          With insMail
          .From = "omar.abid2006@ gmail.com"
          .To = "omar.abid2006@ gmail.com"
          .Subject = "test"
          .Body = "test sending email"
          End With
          SmtpMail.SmtpSe rver = "your smtp server"
          SmtpMail.Send(i nsMail)
          Console.WriteLi ne("Successfull y sent email message" +
          >vbCrLf)
          Catch err As Exception
          MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
          >"Error")
          End Try
          End Sub
          >
          >
          >However, is there a limitation for "express" version or is there
          >something wrong about coding?
          >
          >Thanks...
          In the .NET framework 2 the MailMessage class is in the
          System.Net.Mail namespace

          --

          Comment

          • kimiraikkonen

            #6
            Re: System.Web.Mail namespace?

            On Oct 19, 11:50 pm, "Rad [Visual C# MVP]" <r...@nospam.co mwrote:
            On Fri, 19 Oct 2007 13:26:03 -0700, kimiraikkonen
            >
            >
            >
            <kimiraikkone.. .@gmail.comwrot e:
            Hello, I'm trying to create a basic SMTP mail sender using that code,
            i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
            (system.web.MAI L)
            >
            I'm only allowed to declare under that namespaces with "system.web ":
            >
            System.Wb.AspNe tHostingPermiss ion
            System.Web.AspN etHostingPermis sionAttribute
            System.Web.AspN etHostingPermis sionLevel
            >
            Imports System.Web.mail
            Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
            As System.EventArg s) Handles Button1.Click
            >
            Try
            Dim insMail As New System.()
            With insMail
            .From = "omar.abid2...@ gmail.com"
            .To = "omar.abid2...@ gmail.com"
            .Subject = "test"
            .Body = "test sending email"
            End With
            SmtpMail.SmtpSe rver = "your smtp server"
            SmtpMail.Send(i nsMail)
            Console.WriteLi ne("Successfull y sent email message" +
            vbCrLf)
            Catch err As Exception
            MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
            "Error")
            End Try
            End Sub
            >
            However, is there a limitation for "express" version or is there
            something wrong about coding?
            >
            Thanks...
            >
            In the .NET framework 2 the MailMessage class is in the
            System.Net.Mail namespace
            >
            --http://bytes.thinkersr oom.com
            Thanks, that's true! But still i get decleration errors about
            "insmail", "smtpmail" syntaxes due to not being .net 2.0 classes. What
            should be the exact ones?

            Thanks!

            Comment

            • kimiraikkonen

              #7
              Re: System.Web.Mail namespace?

              Ok, however i managed to configure some code OK.

              Imports System.Net.Mail
              Public Class Form1

              Protected Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
              System.EventArg s) Handles btnSubmit.Click
              Try
              Dim message As New MailMessage(txt To.Text, txtFrom.Text,
              txtSubject.Text , txtBody.Text)
              Dim emailClient As New SmtpClient(txtS MTPServer.Text)
              emailClient.Sen d(message)
              litStatus.Text = "Message Sent"

              Catch ex As Exception
              MsgBox("error")
              End Try

              End Sub

              End Class



              But i get "error" message because my smtp server needs authentication
              (username, password).
              How can i set these?

              Thanks.

              Comment

              • kimiraikkonen

                #8
                Re: System.Web.Mail namespace?

                However, added that authorization codes OK
                but i get still "error" message for some reason.


                Dim SMTPUserInfo As New System.Net.Netw orkCredential(t xtSMTPUser.Text ,
                txtSMTPPass.Tex t)
                emailClient.Use DefaultCredenti als = False
                emailClient.Cre dentials = SMTPUserInfo

                Is there a reliable and FREE Smtp server to test?




                Comment

                • Cor Ligthert[MVP]

                  #9
                  Re: System.Web.Mail namespace?

                  Kimi,

                  Click the menu Projects -Add References -Select in the .Net box the
                  "System.Net.Mai l"

                  Set that import as is written in the other messages (to System.Net.Mail )
                  and it should have to work.

                  Cor

                  Comment

                  • Herfried K. Wagner [MVP]

                    #10
                    Re: System.Web.Mail namespace?

                    "kimiraikko nen" <kimiraikkonen8 5@gmail.comschr ieb:
                    Hello, I'm trying to create a basic SMTP mail sender using that code,
                    i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
                    (system.web.MAI L)
                    Make sure your project contains a reference to "System.Web.dll ".

                    --
                    M S Herfried K. Wagner
                    M V P <URL:http://dotnet.mvps.org/>
                    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                    Comment

                    • Cor Ligthert[MVP]

                      #11
                      Re: System.Web.Mail namespace?

                      Herfried,
                      Make sure your project contains a reference to "System.Web.dll ".
                      >
                      Not so clever in version 2005 it is obsolete.

                      Cor

                      Comment

                      • Rad [Visual C# MVP]

                        #12
                        Re: System.Web.Mail namespace?

                        On Fri, 19 Oct 2007 21:44:03 -0000, kimiraikkonen
                        <kimiraikkonen8 5@gmail.comwrot e:
                        >However, added that authorization codes OK
                        >but i get still "error" message for some reason.
                        >
                        >
                        >Dim SMTPUserInfo As New System.Net.Netw orkCredential(t xtSMTPUser.Text ,
                        >txtSMTPPass.Te xt)
                        emailClient.Use DefaultCredenti als = False
                        emailClient.Cre dentials = SMTPUserInfo
                        >
                        >Is there a reliable and FREE Smtp server to test?
                        How does your SMTP server authenticate you? A quick way to test is
                        Telneting to the server and trying to login from the telnet session
                        using the username and password in your code

                        --

                        Comment

                        • kimiraikkonen

                          #13
                          Re: System.Web.Mail namespace?

                          On Oct 22, 11:58 am, "Rad [Visual C# MVP]" <r...@nospam.co mwrote:
                          On Fri, 19 Oct 2007 21:44:03 -0000, kimiraikkonen
                          >
                          <kimiraikkone.. .@gmail.comwrot e:
                          However, added that authorization codes OK
                          but i get still "error" message for some reason.
                          >
                          Dim SMTPUserInfo As New System.Net.Netw orkCredential(t xtSMTPUser.Text ,
                          txtSMTPPass.Tex t)
                          emailClient.Use DefaultCredenti als = False
                          emailClient.Cre dentials = SMTPUserInfo
                          >
                          Is there a reliable and FREE Smtp server to test?
                          >
                          How does your SMTP server authenticate you? A quick way to test is
                          Telneting to the server and trying to login from the telnet session
                          using the username and password in your code
                          >
                          --http://bytes.thinkersr oom.com
                          Hello,
                          I've done by using Gmail free smtp server. Rad, i enabled SSL and
                          username/passwords as shown above and port 587(not needed
                          actually)There was no need to add special reference (dll).
                          "imports System.Net.Mail " done it.

                          Thanks.

                          Comment

                          Working...