Moonshine
Registered User.
- Local time
- Today, 23:06
- Joined
- Jan 29, 2003
- Messages
- 125
Hi, well after many hours of trying with the standard:
"DoCmd.SendObject acSendQuery, "Appendix A Data Required", acFormatXLS, .Fields![SW Email], , , "Data Needed For Appendix A Forms", rstSubject.Fields![Subject],0"
For some reason the above wouldnt work, it basically is in teh middle of a Do statement, it cycles a recordset, gets the Staff Members Name and Email address, it was the supposed to send an email, with a Excel Spreadsheet attached containing data relevant to them. When i ran this, it sent the first email but would not send the others. At the time there were 52 unique staff members in the record source, but would not send the other 51! It ran the updates to place the relevant information per staff member into a query, but just wouldnt email it.
So, i then look on the Knowledge base, and came up with another way to email, below.
This works fine, it sends out the 52 emails spot on, BUT i cant get it to send the results of a query, as you can see below its looking for an attachment. Does anyone know how i could change this to send the object query with the email? I dont want to have to export the spreadsheets one by one, email it, delete it and do all that for each staff member. At times this table could get to over 200 staff members.
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Scott Holmes")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.Subject = "Data Needed For Appendix A Forms"
.Body = rstSubject.Fields![Subject]
'.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
Set objOutlookAttach = .Attachments.Add("Appendix A Data Required")
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
'.Save
.Send
End With
"DoCmd.SendObject acSendQuery, "Appendix A Data Required", acFormatXLS, .Fields![SW Email], , , "Data Needed For Appendix A Forms", rstSubject.Fields![Subject],0"
For some reason the above wouldnt work, it basically is in teh middle of a Do statement, it cycles a recordset, gets the Staff Members Name and Email address, it was the supposed to send an email, with a Excel Spreadsheet attached containing data relevant to them. When i ran this, it sent the first email but would not send the others. At the time there were 52 unique staff members in the record source, but would not send the other 51! It ran the updates to place the relevant information per staff member into a query, but just wouldnt email it.
So, i then look on the Knowledge base, and came up with another way to email, below.
This works fine, it sends out the 52 emails spot on, BUT i cant get it to send the results of a query, as you can see below its looking for an attachment. Does anyone know how i could change this to send the object query with the email? I dont want to have to export the spreadsheets one by one, email it, delete it and do all that for each staff member. At times this table could get to over 200 staff members.
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Scott Holmes")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.Subject = "Data Needed For Appendix A Forms"
.Body = rstSubject.Fields![Subject]
'.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
Set objOutlookAttach = .Attachments.Add("Appendix A Data Required")
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
'.Save
.Send
End With