send email and use the address which is in a database field

C

cliveawalsh

I am trying to send information to many users ( a report for example) via
email. I have all the email address stored in my contacts table and would
like to be able to set up buttons to send to reports to these email address.
 
N

Niklas Östergren

This can be done by using DoCmd.SendObject

Syntax:
SendObject([ObjectType As AcSendObjectType = acSendNoObject], [ObjectName],
[OutputFormat], [To], [Cc], [Bcc], [Subject], [MessageText], [EditMessage],
[TemplateFile])

Since I don´t know more about your application and not exactly what in this
you need help with I can´t be more specific with my help to you.
But you have to collect the addresses from your application, ex. by Opening
a recordset an loop strough the field containing the addresses you need and
then concatenate these addresses seperated with a semicolon ";" (without the
"").

Then run DoCmd.SendObject where you specifye which report in your
application you want to send. Replace [ObjectName] with the string name of
your report and also replace [To] with a string variable holding the
concatenated e-mailaddresses.

To find out more about how to use DoCmd.SendObject type "DoCmd.SendObject "
in VBE-window and hit F1.

// Niklas


cliveawalsh said:
I am trying to send information to many users ( a report for example) via
email. I have all the email address stored in my contacts table and would
like to be able to set up buttons to send to reports to these email
address.
 
C

cliveawalsh

Thanks Niklas. I have just emailed you about this.

I cant quite get the syntax right.

Im almost there I think but still not sure about the syntax. Im more used
to the expression builder.

I have created a form with a command button on it and this has the
docmd.sendobject attatched to it as an enter statement. The table which
contains the email address is called contacts. The report to be sent is
called letter. The output format needs to be readable by anyone and they
might not have access or xcel.

So far I have this
DoCmd.SendObject acSendReport, Letter, html, [Email Address], , , "Latest
Offers", "Message Txt", YES


Which wont compile because of syntax errors.

Can you help me please???


Niklas Östergren said:
This can be done by using DoCmd.SendObject

Syntax:
SendObject([ObjectType As AcSendObjectType = acSendNoObject], [ObjectName],
[OutputFormat], [To], [Cc], [Bcc], [Subject], [MessageText], [EditMessage],
[TemplateFile])

Since I don´t know more about your application and not exactly what in this
you need help with I can´t be more specific with my help to you.
But you have to collect the addresses from your application, ex. by Opening
a recordset an loop strough the field containing the addresses you need and
then concatenate these addresses seperated with a semicolon ";" (without the
"").

Then run DoCmd.SendObject where you specifye which report in your
application you want to send. Replace [ObjectName] with the string name of
your report and also replace [To] with a string variable holding the
concatenated e-mailaddresses.

To find out more about how to use DoCmd.SendObject type "DoCmd.SendObject "
in VBE-window and hit F1.

// Niklas


cliveawalsh said:
I am trying to send information to many users ( a report for example) via
email. I have all the email address stored in my contacts table and would
like to be able to set up buttons to send to reports to these email
address.
 
N

Niklas Östergren

Try this code in the click event of your command button.:

'============================================
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim strSQL As String
Dim strEmailAddresses As String

Set db = Currentdb()

'Specifying whitch table and what records from that table to use in the
recordset.
strSQL = "SELECT contacts.* FROM contacts"

' Open up the recordset
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)

'Loop through all records in table and concatenate the e-mail addresses
Do Until rec.EOF
strEmailAddresses = strEmailAddresses & ";" & rec![Email
Address]
rec.MoveNext
Loop

'Creating the e-mail and attaching the report named "Letter".
'You need the "" to tell VBA that it´s a string.
DoCmd.SendObject acSendReport, "Letter", html, strEmailAddresses , , ,
"Latest Offers", "Message Txt", True

'Clean up and releasing the recordset.
rec.Close
Set rec = Nothing
'=======================================================
Hopfully this will halp you out. But I recommend you to carefully look
througbh the code and try to understand what it´s doing. If you have any Q
pleas let me know.

// Niklas



cliveawalsh said:
Thanks Niklas. I have just emailed you about this.

I cant quite get the syntax right.

Im almost there I think but still not sure about the syntax. Im more used
to the expression builder.

I have created a form with a command button on it and this has the
docmd.sendobject attatched to it as an enter statement. The table which
contains the email address is called contacts. The report to be sent is
called letter. The output format needs to be readable by anyone and they
might not have access or xcel.

So far I have this
DoCmd.SendObject acSendReport, Letter, html, [Email Address], , , "Latest
Offers", "Message Txt", YES


Which wont compile because of syntax errors.

Can you help me please???


Niklas Östergren said:
This can be done by using DoCmd.SendObject

Syntax:
SendObject([ObjectType As AcSendObjectType = acSendNoObject], [ObjectName],
[OutputFormat], [To], [Cc], [Bcc], [Subject], [MessageText], [EditMessage],
[TemplateFile])

Since I don´t know more about your application and not exactly what in this
you need help with I can´t be more specific with my help to you.
But you have to collect the addresses from your application, ex. by Opening
a recordset an loop strough the field containing the addresses you need and
then concatenate these addresses seperated with a semicolon ";" (without the
"").

Then run DoCmd.SendObject where you specifye which report in your
application you want to send. Replace [ObjectName] with the string name of
your report and also replace [To] with a string variable holding the
concatenated e-mailaddresses.

To find out more about how to use DoCmd.SendObject type "DoCmd.SendObject "
in VBE-window and hit F1.

// Niklas


"cliveawalsh" <[email protected]> skrev i meddelandet
I am trying to send information to many users ( a report for example) via
email. I have all the email address stored in my contacts table and would
like to be able to set up buttons to send to reports to these email
address.
 
A

Arvin Meyer

Z

ZTZ

Hi Guys,

I have been using email function in Access for almost 2 years now. What I
can not figure out is to email users every hour automatically. Is there a
way Access can email reports out to users automatically?

These are live manufacturing reports!

Thanks in advance.

Niklas Östergren said:
Try this code in the click event of your command button.:

'============================================
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim strSQL As String
Dim strEmailAddresses As String

Set db = Currentdb()

'Specifying whitch table and what records from that table to use in the
recordset.
strSQL = "SELECT contacts.* FROM contacts"

' Open up the recordset
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)

'Loop through all records in table and concatenate the e-mail addresses
Do Until rec.EOF
strEmailAddresses = strEmailAddresses & ";" & rec![Email
Address]
rec.MoveNext
Loop

'Creating the e-mail and attaching the report named "Letter".
'You need the "" to tell VBA that it´s a string.
DoCmd.SendObject acSendReport, "Letter", html, strEmailAddresses , , ,
"Latest Offers", "Message Txt", True

'Clean up and releasing the recordset.
rec.Close
Set rec = Nothing
'=======================================================
Hopfully this will halp you out. But I recommend you to carefully look
througbh the code and try to understand what it´s doing. If you have any Q
pleas let me know.

// Niklas



cliveawalsh said:
Thanks Niklas. I have just emailed you about this.

I cant quite get the syntax right.

Im almost there I think but still not sure about the syntax. Im more used
to the expression builder.

I have created a form with a command button on it and this has the
docmd.sendobject attatched to it as an enter statement. The table which
contains the email address is called contacts. The report to be sent is
called letter. The output format needs to be readable by anyone and they
might not have access or xcel.

So far I have this
DoCmd.SendObject acSendReport, Letter, html, [Email Address], , , "Latest
Offers", "Message Txt", YES


Which wont compile because of syntax errors.

Can you help me please???


Niklas Östergren said:
This can be done by using DoCmd.SendObject

Syntax:
SendObject([ObjectType As AcSendObjectType = acSendNoObject], [ObjectName],
[OutputFormat], [To], [Cc], [Bcc], [Subject], [MessageText], [EditMessage],
[TemplateFile])

Since I don´t know more about your application and not exactly what in this
you need help with I can´t be more specific with my help to you.
But you have to collect the addresses from your application, ex. by Opening
a recordset an loop strough the field containing the addresses you need and
then concatenate these addresses seperated with a semicolon ";" (without the
"").

Then run DoCmd.SendObject where you specifye which report in your
application you want to send. Replace [ObjectName] with the string name of
your report and also replace [To] with a string variable holding the
concatenated e-mailaddresses.

To find out more about how to use DoCmd.SendObject type "DoCmd.SendObject "
in VBE-window and hit F1.

// Niklas


"cliveawalsh" <[email protected]> skrev i meddelandet
I am trying to send information to many users ( a report for example) via
email. I have all the email address stored in my contacts table and would
like to be able to set up buttons to send to reports to these email
address.
 
N

Niklas Östrergren

One way of doing that is to create a form and use the form´s Time_Event and
set the timeinterval to 3 600 000 ms.

This time start to run every time the form is opened. So you could close the
form every 3 600 000 ms and reopen it and at the same time, when the form is
reopened send an email. Offcourse should this form have propertie.Visible =
False so the user don´t see it all the time.

If ther´s another better way of doing this I don´t know but this is one way
I can think of!

// Niklas


ZTZ said:
Hi Guys,

I have been using email function in Access for almost 2 years now. What I
can not figure out is to email users every hour automatically. Is there a
way Access can email reports out to users automatically?

These are live manufacturing reports!

Thanks in advance.

Niklas Östergren said:
Try this code in the click event of your command button.:

'============================================
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim strSQL As String
Dim strEmailAddresses As String

Set db = Currentdb()

'Specifying whitch table and what records from that table to use in the
recordset.
strSQL = "SELECT contacts.* FROM contacts"

' Open up the recordset
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)

'Loop through all records in table and concatenate the e-mail addresses
Do Until rec.EOF
strEmailAddresses = strEmailAddresses & ";" & rec![Email
Address]
rec.MoveNext
Loop

'Creating the e-mail and attaching the report named "Letter".
'You need the "" to tell VBA that it´s a string.
DoCmd.SendObject acSendReport, "Letter", html, strEmailAddresses , , ,
"Latest Offers", "Message Txt", True

'Clean up and releasing the recordset.
rec.Close
Set rec = Nothing
'=======================================================
Hopfully this will halp you out. But I recommend you to carefully look
througbh the code and try to understand what it´s doing. If you have any Q
pleas let me know.

// Niklas



"cliveawalsh" <[email protected]> skrev i meddelandet
Thanks Niklas. I have just emailed you about this.

I cant quite get the syntax right.

Im almost there I think but still not sure about the syntax. Im more used
to the expression builder.

I have created a form with a command button on it and this has the
docmd.sendobject attatched to it as an enter statement. The table which
contains the email address is called contacts. The report to be sent is
called letter. The output format needs to be readable by anyone and they
might not have access or xcel.

So far I have this
DoCmd.SendObject acSendReport, Letter, html, [Email Address], , , "Latest
Offers", "Message Txt", YES


Which wont compile because of syntax errors.

Can you help me please???


:

This can be done by using DoCmd.SendObject

Syntax:
SendObject([ObjectType As AcSendObjectType = acSendNoObject], [ObjectName],
[OutputFormat], [To], [Cc], [Bcc], [Subject], [MessageText], [EditMessage],
[TemplateFile])

Since I don´t know more about your application and not exactly what
in
this
you need help with I can´t be more specific with my help to you.
But you have to collect the addresses from your application, ex. by Opening
a recordset an loop strough the field containing the addresses you
need
and
then concatenate these addresses seperated with a semicolon ";"
(without
the
"").

Then run DoCmd.SendObject where you specifye which report in your
application you want to send. Replace [ObjectName] with the string
name
of
your report and also replace [To] with a string variable holding the
concatenated e-mailaddresses.

To find out more about how to use DoCmd.SendObject type "DoCmd.SendObject "
in VBE-window and hit F1.

// Niklas


"cliveawalsh" <[email protected]> skrev i meddelandet
I am trying to send information to many users ( a report for
example)
via
email. I have all the email address stored in my contacts table
and
would
like to be able to set up buttons to send to reports to these email
address.
 
Top