Results 1 to 34 of 34

Thread: vb6 - send email with attachment using smtp

  1. #1
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    vb6 - send email with attachment using smtp

    This little project sends email with attachment, using ssl if required.
    Some part of the code is not mine, but i made this for most people who still find is difficult to send email in vb6, so they can use as a template. it is simple and straight forward

    Name:  sendemail.PNG
Views: 12576
Size:  13.3 KB


    SendEmail.zip
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  2. #2
    Junior Member DanielT's Avatar
    Join Date
    Apr 11
    Location
    Philippines
    Posts
    16

    Re: vb6 - send email with attachment using smtp

    Tested and working! thanks man!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  3. #3
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    Not working with me
    this message

  4. #4
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    i am soory
    this message "the transport failed to connect the server"

  5. #5
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    hello,
    welcome to the forums, i think you should check your
    logon on credentials,
    your Internet connection.
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  6. #6
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    thank you

    but i have connection with internet

  7. #7
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    which email provider settings are you using

    Server ?
    port ?
    ssl ?
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  8. #8
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    mailman.SmtpHost = smtp.gmail.com
    mailman.SmtpPort = 465
    mailman.SMTPSSL = 1

  9. #9
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  10. #10
    Frenzied Member
    Join Date
    Aug 06
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: vb6 - send email with attachment using smtp

    could you post the settings reqd..

  11. #11
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    Thank you very much for your support and I will give you the experience and the result

  12. #12
    New Member
    Join Date
    Jun 11
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    many thanks for great support it is working now

  13. #13
    New Member
    Join Date
    Aug 11
    Posts
    2

    Re: vb6 - send email with attachment using smtp

    Hi everybody!
    this project works for gmail, but it doesn't works for microsoftonline smtp server.

    smtp server: smtp.mail.emea.microsoftonline.com
    port: 587
    with SSL

    The error: -2147220973

    The user and pwd are correct. I cant use them for configure client.

    If I can't do it with CDO.Message, how can do it?

    I'm hopeless.

    Could anybody help me, please?

    Thanks in advance.

    Sonia.

  14. #14
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    {please delete}
    Last edited by coolcurrent4u; Aug 9th, 2011 at 02:57 PM.
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  15. #15
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    what is this error, any message with it.
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  16. #16
    New Member
    Join Date
    Aug 11
    Posts
    2

    Re: vb6 - send email with attachment using smtp

    The error is: -2147220973 - Transport error in server conection.

    I think, CDO doesn't support SSL/TLS authentication.

  17. #17
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    it does support ssl, this app was tested with gmail before posting. make sure that you enable pop access in your email account online first before using the app, and also make sure that you password is correct.
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  18. #18
    New Member malek2610's Avatar
    Join Date
    Jan 12
    Location
    Marseille (France)
    Posts
    3

    Re: vb6 - send email with attachment using smtp

    thank you so much for the code

    it works good when I run it on VB, but when I try to make an exe file it doesn't work, I get this messege

    Compile Error :

    Sub or Function not defined

    Can you help me please !!

  19. #19
    Junior Member PowerProg's Avatar
    Join Date
    Jan 12
    Posts
    17

    Re: vb6 - send email with attachment using smtp

    Thanks
    It's very good

  20. #20
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    @malek2610 i did get that error when i compiled, shich sub or function did it complain about?
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  21. #21
    New Member malek2610's Avatar
    Join Date
    Jan 12
    Location
    Marseille (France)
    Posts
    3

    Re: vb6 - send email with attachment using smtp

    Quote Originally Posted by coolcurrent4u View Post
    @malek2610 i did get that error when i compiled, shich sub or function did it complain about?
    I've problem with "txtInfo" in :

    Code:
    Private Sub txtInfo_GotFocus(Index As Integer)
        txtInfo(Index).SelStart = 0
        txtInfo(Index).SelLength = Len(txtInfo(Index))
    End Sub

  22. #22
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Re: vb6 - send email with attachment using smtp

    Do you have a control array of textboxes called txtInfo?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  23. #23
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    Hello, Please delete this code, its ambiguous

    vb Code:
    1. Private Sub txtInfo_GotFocus(Index As Integer)
    2.     txtInfo(Index).SelStart = 0
    3.     txtInfo(Index).SelLength = Len(txtInfo(Index))
    4. End Sub
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  24. #24
    New Member malek2610's Avatar
    Join Date
    Jan 12
    Location
    Marseille (France)
    Posts
    3

    Re: vb6 - send email with attachment using smtp

    Quote Originally Posted by coolcurrent4u View Post
    Hello, Please delete this code, its ambiguous

    vb Code:
    1. Private Sub txtInfo_GotFocus(Index As Integer)
    2.     txtInfo(Index).SelStart = 0
    3.     txtInfo(Index).SelLength = Len(txtInfo(Index))
    4. End Sub
    Thank you so much, now it works without any problem

  25. #25
    New Member
    Join Date
    May 12
    Posts
    1

    Re: vb6 - send email with attachment using smtp

    you have done an outstanding job, thanks

    please could you let me know how to send 3 x pdf atachments from this e-mailer

    kind regards

    Adie

  26. #26
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,747

    Re: vb6 - send email with attachment using smtp

    I don't know how the rest of you got it to work but I sure don't have any luck with it. I just can't get it to work when using the server smtp.live.com. The port is at 465, Req SSL is checked, username and password are correct and my from email is correct. I always get the same error The transport failed to connect to the server
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  27. #27
    Hyperactive Member
    Join Date
    Jun 12
    Location
    I'm living in VBForum bcz its members deserve respect and appreciation
    Posts
    315

    Re: vb6 - send email with attachment using smtp

    Need Help,
    I have below code i want to record in each sheet only 50 data. Can anyone help me.

    Private Sub print()


    Dim cnn As New ADODB.Connection
    Dim xlApp1 As New Excel.Application
    Dim xlwk As New Excel.Workbook
    Dim xlSheet1 As New Excel.Worksheet
    Dim xlSheet2 As New Excel.Worksheet
    Dim ctr As Long
    Dim SQL As String
    Dim rs

    cnn.ConnectionTimeout = 15
    cnn.CommandTimeout = 30

    g_strDBName = dbPath & "\BarqCell Data\DSS.mdb"
    'creates a new databse conection and sets the conection string
    Set cnn = New ADODB.Connection
    Constring = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source=" & g_strDBName
    cnn.ConnectionString = Constring
    'Opens the database conection

    cnn.Open

    If DTPicker1.Value = "" Then
    MsgBox "please select date"
    Exit Sub
    End If

    SQL = "select number from tblWarehouse_Received where date =#" & DTPicker1.Value & "#"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open SQL, cnn, adOpenDynamic, adLockOptimistic

    xlApp1.Interactive = True

    Set xlwk = xlApp1.Workbooks.Open(App.Path & "\Asia.xls")
    Set xlSheet1 = xlwk.Worksheets("Asia1")
    xlSheet1.Select
    Set xlSheet2 = xlwk.Worksheets("Sheet2")
    xlSheet2.Select
    xlSheet1.Range("B6").Value = Date
    xlSheet2.Range("B6").Value = Date
    ctr = 9 ' start data after headings

    i think i made wrong in below code could you please fix it to me. so i can record only 50data in each sheet.
    Do While Not rs.EOF
    ctr = ctr + 1
    If ctr <= 50 Then xlSheet1.Range("B" & Trim(Str(ctr))).Value = rs("number")
    If ctr > 50 And ctr <= 100 Then xlSheet2.Range("B" & Trim(Str(ctr))).Value = rs("number")
    rs.MoveNext

    Loop


    xlApp1.Visible = True

    'xlwk.Save
    'xlApp.Quit

    'handleError:
    ' If err.Number <> 0 Then
    ' MsgBox "Error #: " & err.Number & vbCrLf & err.Description, vbCritical, "Critical Error"
    ' End If

    End Sub

  28. #28
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    pls post you question the the vb6 general forum, not here
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  29. #29
    Hyperactive Member
    Join Date
    Jun 12
    Location
    I'm living in VBForum bcz its members deserve respect and appreciation
    Posts
    315

    Re: vb6 - send email with attachment using smtp

    I already did. Sorry for confusing. I did post it here by mistake. Thank you for understand and your time to replay me.

  30. #30
    New Member
    Join Date
    Mar 06
    Posts
    12

    Re: vb6 - send email with attachment using smtp

    I am running VB6 on windows 7 ultimate with office 2010
    I run the program and it gives an error:

    The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

    Can anybody help

  31. #31
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: vb6 - send email with attachment using smtp

    check you connection , make sure your gmail password is correct, try it in another computer, then post the result here
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  32. #32
    New Member
    Join Date
    Feb 13
    Posts
    1

    Re: vb6 - send email with attachment using smtp

    Works OK for Yahoo and Gmail. Errors appear if use Hotmail or Exchange. Machine used: PC with Windows 7 Enterprise, Office 2010 Pro installed and exchange used for other stuff.

  33. #33
    New Member
    Join Date
    Mar 13
    Posts
    1

    Re: vb6 - send email with attachment using smtp

    It works!!!!
    Quote Originally Posted by coolcurrent4u View Post
    This little project sends email with attachment, using ssl if required.
    Some part of the code is not mine, but i made this for most people who still find is difficult to send email in vb6, so they can use as a template. it is simple and straight forward

  34. #34
    New Member
    Join Date
    May 13
    Posts
    1

    Re: vb6 - send email with attachment using smtp

    Quote Originally Posted by coolcurrent4u View Post
    check you connection , make sure your gmail password is correct, try it in another computer, then post the result here
    Have the same problem here... When i try using smtp.gmail.com, it works. But when i try using my smtp server, it failed

    I've tried using the same smtp setting in my microsoft outlook, and it works. So that mean there is no problem with my setting and smpt connection

    note : I use Webmail smtp

    Need help please...

    thanks before

Posting Permissions

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