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!

Email multiple attachments in vba 1

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Using the following code that I got from Andrzejek. I have made some small changes(this is the original), and it works great. Now I have the need to send multiple attachments and I can't figure out how to do that. I think the change is in this bit of code.

ACCESS 10, Windows 7


Public Sub SendAMessage(strFrom As String, strTo As String, _
strCC As String, strSubject As String, strTextBody As String, _
Optional strBcc As String, Optional strAttachDoc As String)

On Error GoTo MyErrorHadler

Set objMessage = New CDO.Message

With objMessage
.From = strFrom
.To = strTo
If Len(Trim$(strCC)) > 0 Then
.CC = strCC
End If
If Len(strBcc) > 0 Then
.BCC = strBcc
End If
''' On behalf of
'.Sender = "Bill.Wolf@msn.com"
.Subject = strSubject
.TextBody = strTextBody

If Len(strAttachDoc) > 0 Then
.AddAttachment strAttachDoc
End If

With .Configuration.Fields
.Item(CDO.cdoSMTPServer) = "NTSMTP.ABC.DEF.XYZ"
.Item(CDO.cdoSMTPServerPort) = 25
.Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With
.Send
End With

Set objMessage = Nothing

Exit Sub

Thanks in advance

jpl
 
Just do .AddAttachment multiple times, once for each attachment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top