vb6 - send email with attachment using smtp-VBForums
Results 1 to 39 of 39

Thread: vb6 - send email with attachment using smtp

  1. #1

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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: 23447
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 2011
    Location
    Philippines
    Posts
    16

    Re: vb6 - send email with attachment using smtp

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

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

    Re: vb6 - send email with attachment using smtp

    Not working with me
    this message

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

    Re: vb6 - send email with attachment using smtp

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

  5. #5

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2011
    Posts
    6

    Re: vb6 - send email with attachment using smtp

    thank you

    but i have connection with internet

  7. #7

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2011
    Posts
    6

    Re: vb6 - send email with attachment using smtp

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

  9. #9

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2006
    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 2011
    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 2011
    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 2011
    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2011
    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2012
    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 2012
    Posts
    17

    Re: vb6 - send email with attachment using smtp

    Thanks
    It's very good

  20. #20

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2012
    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 2001
    Location
    Searching for mendhak
    Posts
    58,334

    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2012
    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 2012
    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 2008
    Posts
    8,887

    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


    Anything I post is an example for demonstration purposes only and is not intended to be the solution to your request nor do I claim that it is. If you find that it is useful then it is entirely up to you to make whatever necessary changes you feel are adequate for your purposes.

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

    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2012
    Location
    I'm living in VBForum bcz its members deserve respect and appreciation
    Posts
    333

    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 2006
    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

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    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 2013
    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 2013
    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 2013
    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

  35. #35
    New Member
    Join Date
    Jan 2014
    Posts
    1

    Re: vb6 - send email with attachment using smtp

    I 'd like to download the sendemail.zip, but it does not work. What's wrong?

    Thank you for help!

  36. #36
    Registered User
    Join Date
    Mar 2014
    Posts
    2

    Re: vb6 - send email with attachment using smtp

    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

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


    SendEmail.zip
    cool : i try to remake on a new project, but ..
    there is an error on "Dim lobj_cdomsg As CDO.Message"

    and yellow highlighted "Public Function SendMail(sTo As String, sSubject As String, sFrom As String, _
    sBody As String, sSmtpServer As String, iSmtpPort As Integer, _
    sSmtpUser As String, sSmtpPword As String, _
    sFilePath As String, bSmtpSSL As Boolean) As String"

    how can i fix this ? please help me
    #my_bad_english sorry

  37. #37
    Registered User
    Join Date
    Mar 2014
    Posts
    2

    Re: vb6 - send email with attachment using smtp

    an error appears on
    "Public Function SendMail(sTo As String, sSubject As String, sFrom As String, _
    sBody As String, sSmtpServer As String, iSmtpPort As Integer, _
    sSmtpUser As String, sSmtpPword As String, _
    sFilePath As String, bSmtpSSL As Boolean) As String"
    trying to remake .. but i made a function from command5_click()'s code..

    and VB highlighted "Dim lobj_cdomsg As CDO.Message"
    please help me


    #sorry_4_my_bad_english

  38. #38
    Member
    Join Date
    Mar 2012
    Posts
    46

    Re: vb6 - send email with attachment using smtp

    Nope, try to install this
    Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1
    http://www.microsoft.com/en-us/downl....aspx?id=36771

  39. #39
    Fanatic Member
    Join Date
    Dec 2008
    Posts
    585

    Re: vb6 - send email with attachment using smtp

    Thank you,
    This is working for me.
    I would appreciate it if someone could illustrate how to use BCC with this

    Rob

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.