sending emails with Multiple attachements

atrium

Registered User.
Local time
Today, 17:50
Joined
May 13, 2014
Messages
348
I have created a filed called AttachmentsFld and it contains the full address and file name or each attachment separated by a ; Each of the documents have been converted to .pdf's I can run this for 1 attachment or multiple attachments. If it's multiple I set Me.MultiAttachFlag = -1

I get an error "Object doesn't support this property or method"


I then use the following code to create the email
Code:
 Public Function SendEmailWithAttach()
 '------------------------------------ Send Email with Attachment -------------------
 ' This will create the PDF if the report is setup for it

 Dim strEmail As String
 Dim strMsg As String
 Dim oLook As Object
 Dim oMail As Object
 
 Set oLook = CreateObject("Outlook.Application")
 Set oMail = oLook.createitem(0)
 With oMail
    .To = CStr(Me.SendToEmailFld)    '"john@optionsgrp.com.au"
    .body = "Dear Sir / Madam" & Chr(10) & Chr(10) & "Please find enclosed a self-explanatory communication from XXXXXXXXXXXX." & Chr(10) & Chr(10) & Chr(10) & "Regards" & Chr(10) & Chr(10) & "XXXXXXXX"
    .Subject = " " & Me.SubjectFld
    If Me.MultiAttachFlag = -1 Then
       .Attachments.Add (AttachmentsFld)
    
    Else
       .Attachments.Add (DocPathFld & DocFileNameFld)
    End If
 '********* What is the command to preview instead of send ****  .Display *****
    .Display

 End With
 
 Me.MultiAttachFlag = 0
 Set oMail = Nothing
 Set oLook = Nothing
 End Function
 
Unlike the To field where you can set the property to a string of email addresses, attachments need to be added one by one.

So the command is
.Attachments.add (SingleFileNameWithFullPath)

If your table is storing a concatenated list of attachments, you'll need to separate that list into individual file names and have the Attachments.add statement in a loop. Look up the split function which will be the best way to go.

Otherwise, if you have a multi-valued field in your table, I can't help because I never design such tables and never have had to do it (although I think there is a way).
 
Thank you Cronk

I think you have solved my problem. I can add the attachment address and filename as I deal with each file instead of concatenating them into one field

Thank you
 
Unlike the To field where you can set the property to a string of email addresses, attachments need to be added one by one.

So the command is
.Attachments.add (SingleFileNameWithFullPath)

If your table is storing a concatenated list of attachments, you'll need to separate that list into individual file names and have the Attachments.add statement in a loop. Look up the split function which will be the best way to go.

Otherwise, if you have a multi-valued field in your table, I can't help because I never design such tables and never have had to do it (although I think there is a way).

I know this is an old thread but how did you .Attachments.add each attachment that was from your table. I can loop and get a list of where each attachment is held followed by a ; but how do you add each one individually?
 
The attachments property of an email item is a collection, not a string of file names. If you are looping through a table containing the name and full path of the files to be attached you would have something like the following to add a number of attachments to the collection.
Code:
with myEmailItemObject
do while not rst.eof
    .attachments.add(rst!DocumentName)
    rst.movenext
loop
 

Users who are viewing this thread

Back
Top Bottom