Hi,
I would like to send emails with attachments from within MSACESS 2003.
I have used Microsofts example that allows to send an email with an attahcment to many recipients.
http://support.microso ft.com/?id=318881#appl iesto
What I would like to do is to send Many Attachments to many Recipients. I am failing miserably from the word go.
My main table that stores email address is tbl_Accident_Ca seHandler
I filter the emails to select the required email address with qryCaseHandler
I modified microsofts Module to include my queries and form but even in the most basic form, i get the error '3061 Too Few Parameters. Expected 2.
I have not got near modifying the attachments section. :)
My attachment paths are stored in qryMailingAttac hment as DocPath
These queries are producing the required results.
I am not sure where to go from here.
Thanks in advance for excellent support that is always provided on BYTES.
p.s. Is there a method to collect emails within MSACESS
Micrsofts Module (Modified)
I would like to send emails with attachments from within MSACESS 2003.
I have used Microsofts example that allows to send an email with an attahcment to many recipients.
http://support.microso ft.com/?id=318881#appl iesto
What I would like to do is to send Many Attachments to many Recipients. I am failing miserably from the word go.
My main table that stores email address is tbl_Accident_Ca seHandler
I filter the emails to select the required email address with qryCaseHandler
Code:
SELECT tbl_Accident_CaseHandler.CaseHandlerID, tbl_Accident_CaseHandler.AccidentID, tbl_Accident_CaseHandler.ContactID, tbl_Accident_CaseHandler.SupplierID, tbl_Accident_CaseHandler.CaseHandlerName, tbl_Accident_CaseHandler.CaseHandlerPhone, tbl_Accident_CaseHandler.CaseHandlerEmail AS EmailAddress, tbl_Accident_CaseHandler.CaseHandlerNotes FROM tbl_Accident_CaseHandler WHERE (((tbl_Accident_CaseHandler.AccidentID)=[Forms]![AccidentClaims]![AccidentID]) AND ((tbl_Accident_CaseHandler.ContactID)=[Forms]![AccidentClaims]![txtContactID]));
I have not got near modifying the attachments section. :)
My attachment paths are stored in qryMailingAttac hment as DocPath
Code:
SELECT tbl_AccDocuments.DocumentID, tbl_AccDocuments.AccidentID, tbl_AccDocuments.ContactID, tbl_AccDocuments.DocPath, tbl_AccDocuments.DocDescription, tbl_AccDocuments.SendAsAttachment FROM tbl_AccDocuments WHERE (((tbl_AccDocuments.AccidentID)=[Forms]![AccidentClaims]![AccidentID]) AND ((tbl_AccDocuments.ContactID)=[Forms]![AccidentClaims]![txtContactID]) AND ((tbl_AccDocuments.SendAsAttachment)=True));
I am not sure where to go from here.
Thanks in advance for excellent support that is always provided on BYTES.
p.s. Is there a method to collect emails within MSACESS
Micrsofts Module (Modified)
Code:
Sub SendMessages(Optional AttachmentPath) 'Information Taken from the followinh microsoft website 'http://support.microsoft.com/?id=318881#appliesto 'Add Microsoft Outlook Object 11.0 Library 'Addition for Attachments 'http://en.allexperts.com/q/Using-MS-Access-1440/2010/2/Sending-Multiple-Attachments-via.htm Dim MyDB As Database Dim MyRS As Recordset Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Dim TheAddress As String Set MyDB = CurrentDb Set MyRS = MyDB.OpenRecordset("qryMailingList") MyRS.MoveFirst ' Create the Outlook session. Set objOutlook = CreateObject("Outlook.Application") Do Until MyRS.EOF ' Create the e-mail message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) TheAddress = MyRS![EmailAddress] With objOutlookMsg ' Add the To recipients to the e-mail message. Set objOutlookRecip = .Recipients.Add(TheAddress) objOutlookRecip.Type = olTo ' Add the Cc recipients to the e-mail message. If (IsNull(Forms!SendEmail!ccAddress)) Then Else Set objOutlookRecip = .Recipients.Add(Forms!SendEmail!ccAddress) objOutlookRecip.Type = olCC End If ' Set the Subject, the Body, and the Importance of the e-mail message. .Subject = Forms!SendEmail!Subject .Body = Forms!SendEmail!MainText .Importance = olImportanceHigh 'High importance 'Add the attachment to the e-mail message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve the name of each Recipient. For Each objOutlookRecip In .Recipients objOutlookRecip.Resolve If Not objOutlookRecip.Resolve Then objOutlookMsg.Display End If Next .Send End With MyRS.MoveNext Loop Set objOutlookMsg = Nothing Set objOutlook = Nothing End Sub
Comment