how to configer mail script

agorman

Registered User.
Local time
Today, 11:23
Joined
Dec 30, 2006
Messages
68
Hi,

I have this script (below) which I got from this forum but am not sure how to configure it, especially the last line.

I have a form for each personal record with an email field and a tag yes/no box. I have created a query called emailQuery, calling up the field called 'EmailAddress' if the tag box is yes.

I have linked the script in the BV editor to a button in a form which I want to use to to launch my mail window with the selected (tagged) email addresses placed into the BCC.
I do not need to add attachments - just plain text emails sent to selected recipients.

Can't for the life of me figure out how to get it to work. If anyone can help, I would be very grateful.

Thanks

Adrian

I use Access 2003


Dim stDocName As String
Dim stToName As String
Dim stCCName As String
Dim stBCCName As String
Dim stSubject As String
Dim stMessage As String

stDocName = "emailQuery" 'Below in Docmd insert acSendTable for table, acSendReport for report or acSendQuery for query
stToName = "EmailAddress" 'This could also be a field picked up by your query or report
stCCName = "Insert cc email adresses" 'This could also be a field picked up by your query or report
stBCCName= "Insert bcc email adresses" 'This could also be a field picked up by your query or report
stSubject = "Subject text"
stMessage = "Message" 'This could also be a field picked up by your query or report


DoCmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
 
Thanks for that, it explains what everything does, but not how to use it, for example the last line: (DoCmd.SendObject ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile), do i delete things, where do I insert 'acSendQuery', etc etc.

Maybe what I want to achieve is to much.

Thanks again
 
acsendquery is one of the available constants for the objecttype argument . . .
 
When you start typing Docmd.sendobject then your intellisense should kick in and show you which argument to type in next, and which constants are available for each argument. Are you seeing that?
 
Hi,

Yes I can see that. Do I type everything in, including brackets ?, I don't know what these would refer to - ObjectType, ObjectName, OutputFormat

below is what is on the last line already


DoCmd.SendObject ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile

Thanks again

Adrian
 
You don't need to type in the brackets, each argument is like a fill-in-the-blank. So where it says Object type, fill in the object type (you should have a list of constants to choose from when you get there). Then type a comma, then where it says object name you type in the name of the object you are sending, like "MyObjectName", then type a comma, etc. until all of the arguments are filled in.
 
Thanks Alisa,

Just to clarify then:

if I want to call email addresses from the query would I add stDocName, and replace Bcc, with stBCCName, like below ?


DoCmd.SendObject ObjectType, ObjectName, stDocName, stBCCName
 
Hi again,

I have tried diffrent things on the last line and cannot make any sense of it. Is it possible for you to show me an example of what the last line might look like in line with the other coding?

Thanks


Private Sub Command95_Click()

Dim stDocName As String
Dim stToName As String
Dim stCCName As String
Dim stBCCName As String
Dim stSubject As String
Dim stMessage As String

stDocName = "emailQuery" 'Below in Docmd insert acSendTable for table, acSendReport for report or acSendQuery for query
stToName = "EmailAddress" 'This could also be a field picked up by your query or report
stCCName = "" 'This could also be a field picked up by your query or report
stBCCName = "" 'This could also be a field picked up by your query or report
stSubject = ""
stMessage = "" 'This could also be a field picked up by your query or report

DoCmd.SendObject

End Sub
 

Users who are viewing this thread

Back
Top Bottom