I am looking to be able to send an email from Access with multiple attachments (these are previously saved files outside of the Db). The problem I face is that the number of attachments will vary, but its never more than 5
So what I was looking to do was build a string with the full file path of each document (call it "AttachmentFiles") and use the following code to send it:
Dim objOutlook As Object
Dim objOutlookMsg As Object
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0)
.To = ""
.Subject = "Test"
.Body = "Hi "
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
To build the AttachmentFiles string I was looking to use something like this - but I don't know what would be an appropriate seperator (ie a ; as you'd have between email addresses)
Dim AttachmentFiles as string
AttachmentFiles = ""
If Not IsMissing("C:\Users\Public\Documents\Example1.pdf") Then
AttachmentFiles = "C:\Users\Public\Documents\Example1.pdf" **** + a seperator? '****
If Not IsMissing("C:\Users\Public\Documents\Example2.pdf") Then
AttachmentFiles = AttachmentFiles & "C:\Users\Public\Documents\Example2.pdf" '**** + a seperator? '****
If Not IsMissing("C:\Users\Public\Documents\Example3.pdf") Then
AttachmentFiles = AttachmentFiles & "C:\Users\Public\Documents\Example3.pdf"
' etc etc
Is this the right way to do it & if so how do I seperate the attachments?
Anyone know a different method to achieve this?