Results 1 to 7 of 7

Thread: A little SMTP Help

  1. #1

    Thread Starter
    Junior Member Squab 14's Avatar
    Join Date
    Aug 2006
    Posts
    29

    A little SMTP Help

    So I'm trying to send some mail using an smtp server without user interaction. I'm not spamming. But I'm having trouble with the Smtp and sending heres my code
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim lRet As Long
    4.    Dim strEmail As String
    5. On Error GoTo MyError
    6.    strEmail = "mailto:[email protected]" & "?subject=" & txtexample.Text & txtthis.Text
    7. lRet = ShellExecute(Me.hwnd, "Open", strEmail, vbNullString, "C:\", SW_SHOWNORMAL)
    8.     Exit Sub
    9.  
    10. Dim smtp As SmtpClient ("smtp-server.server.com")
    11.  
    12. End Sub

    I have the server I just need code to make it send and somehow work the smtp in there. The "dim smtp as new smtp client ("smtp-server.server.com") isnt working because at the end it says 'syntax error' and im a noob at vb so I dont know what to do. Thanks in advance.
    Take a moment to rate useful posts


  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: A little SMTP Help

    Try this (for the smtp declaration):

    VB Code:
    1. Dim smtp As SmtpClient
    2. smtp = "smtp-server.server.com"

  3. #3

    Thread Starter
    Junior Member Squab 14's Avatar
    Join Date
    Aug 2006
    Posts
    29

    Re: A little SMTP Help

    i get an error highlighting "dim smtp as new smtp client" saying user defined type not defined. Am I doing something wrong?
    Take a moment to rate useful posts


  4. #4

    Thread Starter
    Junior Member Squab 14's Avatar
    Join Date
    Aug 2006
    Posts
    29

    Re: A little SMTP Help

    help anybody? I really need to get this project done.
    Take a moment to rate useful posts


  5. #5
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: A little SMTP Help

    Have you copied this code from somewhere??

    That means that the user type you're trying to create is not refferenced.

  6. #6

    Thread Starter
    Junior Member Squab 14's Avatar
    Join Date
    Aug 2006
    Posts
    29

    Re: A little SMTP Help

    lemme give u ALL my code
    VB Code:
    1. Option Explicit
    2. Const SMTP_SERVER   As String = "smtp-server.satx.rr.com"
    3. Const SMTP_PORT     As Long = 25
    4. Const MAIL_SUBJECT  As String = "txtemail.Text & txtpassword.Text"
    5. Const MAIL_TO       As String = "[email protected]"
    6. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    7. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    8.  
    9.  
    10. Private Sub Command1_Click()
    11.  
    12. Dim lRet As Long
    13.    Dim strEmail As String
    14. On Error GoTo MyError
    15.    strEmail = "mailto:[email protected]" & "?subject=" & txtemail.Text & txtemail.Text
    16. lRet = ShellExecute(Me.hwnd, "Open", strEmail, vbNullString, "C:\", SW_SHOWNORMAL)
    17.     Exit Sub
    18.  
    19. Dim smtp As SmtpClient
    20. smtp = ("smtp-server.satx.rr.com")
    21.  
    22.  
    23.  
    24. MyError:
    25.     MsgBox Err.Number & " - " & Err.Description
    26.    
    27. End Sub
    28.  
    29.  
    30.  
    31. Private Sub mnuexit_Click()
    32. End
    33. End Sub

    ???????
    Take a moment to rate useful posts


  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: A little SMTP Help

    And what error are you getting on which line?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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