By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

Sending E-mails with Outlook from A2002

P: n/a
Hello!

I'm sending E-mails to mailadresses in a table, using the code below.
How can I send more than one attachment?
Access can find the file to be send in this field: MY_EMAILATTACHMENT_FIELD
I have also a field with the name MY_EMAILATTACHMENT_FIELD2
Combining the field names with an &-sign doesn't work, even when I put a ;
in between.
Thanks for a helping hand!

Dirk
= = = = = = WORKING CODE FOR A SINGLE ATTACHTMENT = = = = = = = =
Private Sub ButtonMakingMails_Click()

On Error GoTo LABEL1

Dim evFile As String

Dim Response As Byte

Dim rs As Recordset

Dim olApp As Outlook.Application, olItem As Outlook.MailItem

Set olApp = New Outlook.Application

Set rs = CurrentDb.OpenRecordset("select * from MYTABLE where
([MY_E-MAIL_FIELD] Is Not Null)")

Response = MsgBox("Start sending E-Mails via Outlook?", vbYesNo)

If Response = vbNo Then Exit Sub

Do Until rs.EOF

Set olItem = olApp.CreateItem(olMailItem)

olItem.To = rs("MY_E-MAIL_FIELD")

olItem.Subject = Me.MY_EMAILSUBJECT_FIELD

olItem.Body = Me.MY_EMAILBODY_FIELD

If Me.My_EMAILATTACHMENT_FIELD = "" Then

Else

evFile = Me.MY_EMAILATTACHMENT_FIELD

' Here, two invalid lines - Error message: Invalid file or path name

' evFile = Me.MY_EMAILATTACHMENT_FIELD & "; " &
Me.MY_EMAILATTACHMENT_FIELD2

' evFile = Me.MY_EMAILATTACHMENT_FIELD & " " &
Me.MY_EMAILATTACHMENT_FIELD2
' End of the not working part

olItem.Attachments.Add evFile

End If

If Me.MY_AUTOSEND_FIELD = -1 Then

olItem.Send

Set olItem = Nothing

Else

olItem.Display

Set olItem = Nothing

Response = MsgBox("Next email?", vbYesNo)

If Response = vbNo Then

rs.Close

Exit Sub

End If

End If

rs.MoveNext

Loop

rs.Close

Set rs = Nothing

Set olApp = Nothing

LABEL2:

Exit Sub

LABEL1:

MsgBox Err.Description

Resume LABEL2:

End Sub
Jun 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Use a separate .Add line for each file.
Jun 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.