Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Attachment Email Via VBA

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

I am hoping to use the coding below to send an email with 4 attachments, the problem is the atachments have different times and dates on so i have to use the variables to create the attahment.

How can i get this into this coding.

Code:
 Dim blnSuccessful As Boolean
    Dim strHTML As String
        
    strHTML = "Hi," & vbCrLf & vbCrLf _
    & "Please find attached the latest update, this report has been automatically generated." & vbCrLf & vbCrLf _
    & "If you have any queries, would you please let me know." & vbCrLf & vbCrLf _
     & "Regards" & vbCrLf
  
   
    blnSuccessful = FnSafeSendEmail("test@test.com", _
                                         "Update for " & Format(Range("d4").Value, "hh.mm.ss") & ".", _
                                         strHTML, _
                                         "C:\MyAttachmentFile1.txt; C:\MyAttachmentFile2.txt", _
                                         "cc_recipient@domain.com", _
                                         "bcc_recipient@domain.com")
    If blnSuccessful Then
    
        MsgBox "E-mail message sent successfully!"
        
    Else
    
        MsgBox "Failed to send e-mail!"
    
    End If

the attachment code is like this

Code:
pname = "U:\private\Interval Report\Site Return " & Format(rrdate, "yyyy-mm-dd hh-mm") & ".xls"


Hope this is of use, Rob.[yoda]
 
Something like:
Code:
blnSuccessful = FnSafeSendEmail("test@test.com", _
                                         "Update for " & Format(Range("d4").Value, "hh.mm.ss") & ".", _
                                         strHTML, _
                                         pname & "; " &  pname2, _
                                         "cc_recipient@domain.com", _
                                         "bcc_recipient@domain.com")
Hope this helps

HarleyQuinn
---------------------------------
Black coat, white shoes, black hat, cadillac. The boy's a timebomb!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
thanks trying it now, will let you know

Hope this is of use, Rob.[yoda]
 
it worked thanks, this should help a lot,

Hope this is of use, Rob.[yoda]
 
Glad I could help.

HarleyQuinn
---------------------------------
Black coat, white shoes, black hat, cadillac. The boy's a timebomb!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top