Results 1 to 5 of 5

Thread: Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

    Hello everyone. I am using SMTP Send Mail for VB6.0. Everythig works great except I am only able to send one attachment at a time. Does anyone know how I can send 2 attachments with an email using this component?

    Here is my code.
    VB Code:
    1. poSendMail.Subject = "Profit and loss statement."
    2. poSendMail.Attachment = "C:\P&L-" & Trim(Reports.Combo3.Text) & "-" & Trim(Reports.Combo1.Text) & ".pdf"
    3. poSendMail.Attachment = "C:\ServiceAnalysis-" & Trim(Reports.Combo3.Text) & "-" & Trim(Reports.Combo1.Text) & ".pdf"
    4. poSendMail.Send
    5. Set poSendMail = Nothing
    The preceding code just sends the 2nd attached file, not the first one.
    I also tried posendmail.attachment file1 & "," & file2. This doesn't work either. I also tried it with a semicolon instead of a comma.

    Thanks
    David Wilhelm

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

    This link demonstrates how to send mail with multiple attachments using VBSendMail.

    Note: I found it through Goggle, but have not actually used it.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Re: Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

    Thanks Hack, I found that same article and tried the comma separater but it did not work for me.
    David Wilhelm

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

    Quote Originally Posted by indydavid32
    Thanks Hack, I found that same article and tried the comma separater but it did not work for me.
    As you just posted a snippet of the code, I'm not sure if you are doing this or not, but the routine begins with: set poSendMail = new vbSendMail.clsSendMail

    Are you doing the Set statement?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Re: Multiple attachments with VBSendMail (SMTP Send Mail for VB6.0)

    Hack, here is my code. Nothing fancy.
    VB Code:
    1. Set poSendMail = New vbSendMail.clsSendMail
    2.         poSendMail.SMTPHost = "202.101.8.61"
    3.         poSendMail.POP3Host = "202.101.8.61"
    4.        
    5.         poSendMail.From = st
    6.         Debug.Print strEmail
    7.         poSendMail.Recipient = strEmail
    8.        
    9.         poSendMail.ReplyToAddress = st
    10.         poSendMail.Subject = "Profit and loss statement - Store #" & Trim(Combo3.Text)
    11.        
    12.         st1 = "C:\P&L-" & Trim(Reports.Combo3.Text) & "-" & Trim(Reports.Combo1.Text) & ".pdf"
    13.         st2 = "C:\Expenses-" & Trim(Reports.Combo3.Text) & "-" & Trim(Reports.Combo1.Text) & ".pdf"
    14.         poSendMail.Attachment = st1 & ", " & st1
    15.         poSendMail.Send
    I get an error message that says "Run-time error '52'; Bad file name or number". In debug mode, I try the files individualy without the comma and both files attached that way. So it's not my files. It's the comma.

    Thanks
    Last edited by indydavid32; May 6th, 2005 at 03:37 PM.
    David Wilhelm

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