dbTalk Databases Forums  

Multiple attachments in an email

comp.databases.ms-access comp.databases.ms-access


Discuss Multiple attachments in an email in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
franc sutherland
 
Posts: n/a

Default Multiple attachments in an email - 03-03-2008 , 11:35 AM






Hi,
I'm using the DoCmd.SendObject command to email shipping documents.
Often there is more than one document to be emailed, but when I use
the DoCmd.SendObject I can't see an option for more than one object,
and it ends up being multiple emails with single attachments.
Does anyone know how to automate attaching multiple objects to a
single email?
Thanks,
Franc.

Reply With Quote
  #2  
Old   
paii, Ron
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-03-2008 , 01:19 PM







"franc sutherland" <franc.sutherland (AT) googlemail (DOT) com> wrote

Quote:
Hi,
I'm using the DoCmd.SendObject command to email shipping documents.
Often there is more than one document to be emailed, but when I use
the DoCmd.SendObject I can't see an option for more than one object,
and it ends up being multiple emails with single attachments.
Does anyone know how to automate attaching multiple objects to a
single email?
Thanks,
Franc.
Here is a function I put together with examples from this group

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function EmailAttach(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, _
astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errEmailAttach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject
.ReadReceiptRequested = True

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Add (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
EmailAttach = True
Exit Function

errEmailAttach:

MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
EmailAttach = False

End Function




Reply With Quote
  #3  
Old   
Tony Toews [MVP]
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-03-2008 , 01:36 PM



franc sutherland <franc.sutherland (AT) googlemail (DOT) com> wrote:

Quote:
I'm using the DoCmd.SendObject command to email shipping documents.
Often there is more than one document to be emailed, but when I use
the DoCmd.SendObject I can't see an option for more than one object,
and it ends up being multiple emails with single attachments.
Does anyone know how to automate attaching multiple objects to a
single email?
That's one of the many limitations of SendObject.

SendObject's twenty limitations
http://www.granite.ab.ca/access/email/sendobject.htm

You need to use a different solution. One has been posted for Outlook. Also see
Microsoft Access Email FAQ http://www.granite.ab.ca/access/email.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/


Reply With Quote
  #4  
Old   
lyle fairfield
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-03-2008 , 02:01 PM



"Tony Toews [MVP]" <ttoews (AT) telusplanet (DOT) net> wrote in
news:smkos35iinl6685fajlav0n93kpbo3t4g8 (AT) 4ax (DOT) com:

Quote:
SendObject's twenty limitations
I can let you have some room on my site if you'd like to list them all! :-)


Reply With Quote
  #5  
Old   
franc sutherland
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-03-2008 , 04:30 PM



Hi,
Thanks for taking a look.
I'm afraid I can't get it to work however.
How do I input the array showing the locations of the objects to
send?
The final variable says ' ) as integer'. I don't know what to put in
there?
Sorry to be a pain, I'm still quite new to this stuff.
Thanks,
Franc.

paii, Ron wrote:
Quote:
"franc sutherland" <franc.sutherland (AT) googlemail (DOT) com> wrote in message
news:3c9f84ff-4cdc-428a-a3a4-31eec4ea9eae (AT) d21g2000prf (DOT) googlegroups.com...
Hi,
I'm using the DoCmd.SendObject command to email shipping documents.
Often there is more than one document to be emailed, but when I use
the DoCmd.SendObject I can't see an option for more than one object,
and it ends up being multiple emails with single attachments.
Does anyone know how to automate attaching multiple objects to a
single email?
Thanks,
Franc.

Here is a function I put together with examples from this group

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function EmailAttach(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, _
astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errEmailAttach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject
.ReadReceiptRequested = True

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Add (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
EmailAttach = True
Exit Function

errEmailAttach:

MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
EmailAttach = False

End Function

Reply With Quote
  #6  
Old   
paii, Ron
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-04-2008 , 07:35 AM



See inline comments

"franc sutherland" <franc.sutherland (AT) googlemail (DOT) com> wrote

Quote:
Hi,
Thanks for taking a look.
I'm afraid I can't get it to work however.
How do I input the array showing the locations of the objects to
send?
In the event procedure where you now have DoCmd.SendObject; declare an array
of type string. fill the array with paths of the files you want to attach.
You will need to create these files beforehand.

dim fPath(2) as string

fPath(0) = "c:\test\Path\file.txt"
fPath(1) = "c:\test\Path\file2.txt"

Call EmailSend(Someone (AT) noname (DOT) com, "Test message with attachments", "This is
a test",fPath, 2, False)

Quote:
The final variable says ' ) as integer'. I don't know what to put in
there?
I normaly put False to preview the message before sending. True will send
the message without preview, which on most system will generate a warning
message from windows.

Quote:
Sorry to be a pain, I'm still quite new to this stuff.
Thanks,
Franc.

paii, Ron wrote:
"franc sutherland" <franc.sutherland (AT) googlemail (DOT) com> wrote in message

news:3c9f84ff-4cdc-428a-a3a4-31eec4ea9eae (AT) d21g2000prf (DOT) googlegroups.com...
Hi,
I'm using the DoCmd.SendObject command to email shipping documents.
Often there is more than one document to be emailed, but when I use
the DoCmd.SendObject I can't see an option for more than one object,
and it ends up being multiple emails with single attachments.
Does anyone know how to automate attaching multiple objects to a
single email?
Thanks,
Franc.

Here is a function I put together with examples from this group

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function EmailAttach(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, _
astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errEmailAttach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject
.ReadReceiptRequested = True

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Add (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
EmailAttach = True
Exit Function

errEmailAttach:

MsgBox "The following error was noted : " & Err.Description &
Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
EmailAttach = False

End Function



Reply With Quote
  #7  
Old   
Tony Toews [MVP]
 
Posts: n/a

Default Re: Multiple attachments in an email - 03-07-2008 , 07:43 PM



lyle fairfield <lylefa1r (AT) yah00 (DOT) ca> wrote:

Quote:
SendObject's twenty limitations

I can let you have some room on my site if you'd like to list them all! :-)
<smile>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.