I'm trying to create a VBA routine that allows me to send
multiple attachments in one e-mail. The full path
information of each attachment is stored into one table
named emailattachments. I'm iterating through the table
but for some reason only 1 attachment is picked up.
Does anyone see what I'm doing wrong here.
Thanks.
Dim MyDB As Database, MySet As Recordset
Dim strMsg As String
Dim retval As Integer
Dim stremailto As String
Dim qdf As QueryDef
Dim prm As Parameter
Dim pathattachment As String
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("emailattachments",
DB_OPEN_DYNASET)
'On Error GoTo Send_Err
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With MySet
.MoveFirst
Do While Not .EOF
With objOutlookMsg
.To = "
[email protected]"
.Subject = "Automated Message: INCOMING REQUEST"
.Body = Nz("Double-Click to Open attachment(s)...")
.Attachments.Add (MySet!fldfullpathattachment)
.Recipients.ResolveAll
.Send
End With
.MoveNext
Loop
.Close
End With
DoCmd.Hourglass False
Set objOutlook = Nothing
'GoTo Send_End
'Send_Err:
' MsgBox ("The message to " & stremailto & " could not
be sent. The name may not exist in Outlook or may not be
unique. Click on OK to open the message, then click on
the 'Check names' button and select a recipient or close
the message.")
' objOutlookMsg.Display
'Send_End:
' DoCmd.Hourglass 0