Using Two Fields on a Form to Select Email Addresses from a Table

A

ADB_Seeker

I've searched other posts and not found one that deals with my specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two fields
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two fields to get the email addresses from my
ASSIGNEES table and then create an email (with these two email addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these fields come has an ID
field, which I'm not including in the query. In the Criteria under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or [Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In the
Event Procedure for the Command Button (named COMPLETED) I have the following
code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO NUMBER IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER], strMsgBody, True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the Origniator's and
Requester's names, but not email addresses.
Also, I need a semicolon & space between the two email addresses to separate
them in the email.

I am new to Access and code. Thank you in advance for your assistance!
Linda
 
M

Mark A. Sam

Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand about the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam
 
A

ADB_Seeker

Mark,
Thank you for your response. The email address is located in the Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is approved
and want the code to look in the Originator and Requester Name fields to get
their names, match them to the names in Column 2 of the Assignee table, and
then use their email addresses in column 3 of the Assignee Table to send one
email to both of them. Email addresses are usually separated by a semicolon
and a space, which is why I was asking about how to put that in the code.
Thank you for your help!

Mark A. Sam said:
Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand about the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

ADB_Seeker said:
I've searched other posts and not found one that deals with my specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two controls to get the email addresses from my
ASSIGNEES table and then create an email (with these two email addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls come has an
ID field, which I'm not including in the query. In the Criteria under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or [Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In the
Event Procedure for the Command Button (named COMPLETED) I have the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER], strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the Origniator's and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your assistance!
Linda
 
M

Mark A. Sam

Linda,

I think you are not understanding the Parameters for the SendFile method:

docmd.SendObject
ObjectType,ObjectName,OutputFormat,[To],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

The Parameter [To] is for an email address only, not a name and email
address. I am not sure if you can specify multiple addresses seperated by
comma's, but I think not. What you can do is sent it twice like this:

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address1],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address2],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

You can put the field name in instead of using the strToWhom variable.

I hope that makes sense.

God Bless,

Mark


ADB_Seeker said:
Mark,
Thank you for your response. The email address is located in the Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is approved
and want the code to look in the Originator and Requester Name fields to
get
their names, match them to the names in Column 2 of the Assignee table,
and
then use their email addresses in column 3 of the Assignee Table to send
one
email to both of them. Email addresses are usually separated by a
semicolon
and a space, which is why I was asking about how to put that in the code.
Thank you for your help!

Mark A. Sam said:
Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand about
the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

ADB_Seeker said:
I've searched other posts and not found one that deals with my specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two
controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two controls to get the email addresses from my
ASSIGNEES table and then create an email (with these two email
addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and
EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls come
has an
ID field, which I'm not including in the query. In the Criteria under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or [Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In the
Event Procedure for the Command Button (named COMPLETED) I have the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER], strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the Origniator's
and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your
assistance!
Linda
 
A

ADB_Seeker

Thanks, Mark.
I will change my code to your suggestion for getting the email to send
twice, which will solve the semicoloon/space issue.

I'm not understanding how to get Access to look at the name in the controls
[Requester] and [Originator] on the form, use this information to match the
name in the Assignees Table and then pull the email addresses that match
those names from column 3 in this table. I'm using a query to do this.

My challenge is to get the email address only in [TO] and not the name,
which for some reason is populating the [TO] area. I want the code to look at
the names in the form controls mentioned above and then select the email
addresses associated with those names from a specific table and it's not
working. So, I think my issue is with the code in the query and not the
SendObject, but I'm not 100% sure. I hope I've explained my delimma better
this time.

Thank you for your patience and assistance!

Mark A. Sam said:
Linda,

I think you are not understanding the Parameters for the SendFile method:

docmd.SendObject
ObjectType,ObjectName,OutputFormat,[To],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

The Parameter [To] is for an email address only, not a name and email
address. I am not sure if you can specify multiple addresses seperated by
comma's, but I think not. What you can do is sent it twice like this:

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address1],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address2],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

You can put the field name in instead of using the strToWhom variable.

I hope that makes sense.

God Bless,

Mark


ADB_Seeker said:
Mark,
Thank you for your response. The email address is located in the Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is approved
and want the code to look in the Originator and Requester Name fields to
get
their names, match them to the names in Column 2 of the Assignee table,
and
then use their email addresses in column 3 of the Assignee Table to send
one
email to both of them. Email addresses are usually separated by a
semicolon
and a space, which is why I was asking about how to put that in the code.
Thank you for your help!

Mark A. Sam said:
Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand about
the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

I've searched other posts and not found one that deals with my specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two
controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two controls to get the email addresses from my
ASSIGNEES table and then create an email (with these two email
addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and
EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls come
has an
ID field, which I'm not including in the query. In the Criteria under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or [Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In the
Event Procedure for the Command Button (named COMPLETED) I have the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER], strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the Origniator's
and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your
assistance!
Linda
 
M

Mark A. Sam

Linda,

This is difficult to visualize in my head. If you have a small db, send it
to me at
MarkASam***@***msn.com. Remove the Asterisks (*). If you have a seperate
db for the data send that also and I'll look at it. When you send a
database either zip it or change the extention to .mdx (for version
2000-2003 databases) or accdx (for version 2007 databases).

God Bless,

Mark


ADB_Seeker said:
Thanks, Mark.
I will change my code to your suggestion for getting the email to send
twice, which will solve the semicoloon/space issue.

I'm not understanding how to get Access to look at the name in the
controls
[Requester] and [Originator] on the form, use this information to match
the
name in the Assignees Table and then pull the email addresses that match
those names from column 3 in this table. I'm using a query to do this.

My challenge is to get the email address only in [TO] and not the name,
which for some reason is populating the [TO] area. I want the code to look
at
the names in the form controls mentioned above and then select the email
addresses associated with those names from a specific table and it's not
working. So, I think my issue is with the code in the query and not the
SendObject, but I'm not 100% sure. I hope I've explained my delimma
better
this time.

Thank you for your patience and assistance!

Mark A. Sam said:
Linda,

I think you are not understanding the Parameters for the SendFile method:

docmd.SendObject
ObjectType,ObjectName,OutputFormat,[To],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

The Parameter [To] is for an email address only, not a name and email
address. I am not sure if you can specify multiple addresses seperated
by
comma's, but I think not. What you can do is sent it twice like this:

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address1],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address2],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

You can put the field name in instead of using the strToWhom variable.

I hope that makes sense.

God Bless,

Mark


ADB_Seeker said:
Mark,
Thank you for your response. The email address is located in the
Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is
approved
and want the code to look in the Originator and Requester Name fields
to
get
their names, match them to the names in Column 2 of the Assignee table,
and
then use their email addresses in column 3 of the Assignee Table to
send
one
email to both of them. Email addresses are usually separated by a
semicolon
and a space, which is why I was asking about how to put that in the
code.
Thank you for your help!

:

Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand
about
the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

I've searched other posts and not found one that deals with my
specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two
controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two controls to get the email addresses from
my
ASSIGNEES table and then create an email (with these two email
addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and
EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls come
has an
ID field, which I'm not including in the query. In the Criteria
under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or
[Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In
the
Event Procedure for the Command Button (named COMPLETED) I have the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for
EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO
NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER],
strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the
Origniator's
and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your
assistance!
Linda
 
A

ADB_Seeker

Mark,
I posted a response, but don't see it so I'm posting again.
Thank you for all your help. Unfortunately at this time, I don't have a
small sample db that I can send. I will continue researching and working with
it. I'm sure it is something simple that I'm overlooking.

Thank you for all your assistance and patience!

Best regards,
Linda

Mark A. Sam said:
Linda,

This is difficult to visualize in my head. If you have a small db, send it
to me at
MarkASam***@***msn.com. Remove the Asterisks (*). If you have a seperate
db for the data send that also and I'll look at it. When you send a
database either zip it or change the extention to .mdx (for version
2000-2003 databases) or accdx (for version 2007 databases).

God Bless,

Mark


ADB_Seeker said:
Thanks, Mark.
I will change my code to your suggestion for getting the email to send
twice, which will solve the semicoloon/space issue.

I'm not understanding how to get Access to look at the name in the
controls
[Requester] and [Originator] on the form, use this information to match
the
name in the Assignees Table and then pull the email addresses that match
those names from column 3 in this table. I'm using a query to do this.

My challenge is to get the email address only in [TO] and not the name,
which for some reason is populating the [TO] area. I want the code to look
at
the names in the form controls mentioned above and then select the email
addresses associated with those names from a specific table and it's not
working. So, I think my issue is with the code in the query and not the
SendObject, but I'm not 100% sure. I hope I've explained my delimma
better
this time.

Thank you for your patience and assistance!

Mark A. Sam said:
Linda,

I think you are not understanding the Parameters for the SendFile method:

docmd.SendObject
ObjectType,ObjectName,OutputFormat,[To],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

The Parameter [To] is for an email address only, not a name and email
address. I am not sure if you can specify multiple addresses seperated
by
comma's, but I think not. What you can do is sent it twice like this:

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address1],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address2],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

You can put the field name in instead of using the strToWhom variable.

I hope that makes sense.

God Bless,

Mark


Mark,
Thank you for your response. The email address is located in the
Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is
approved
and want the code to look in the Originator and Requester Name fields
to
get
their names, match them to the names in Column 2 of the Assignee table,
and
then use their email addresses in column 3 of the Assignee Table to
send
one
email to both of them. Email addresses are usually separated by a
semicolon
and a space, which is why I was asking about how to put that in the
code.
Thank you for your help!

:

Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand
about
the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

I've searched other posts and not found one that deals with my
specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains two
controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use the
information from these two controls to get the email addresses from
my
ASSIGNEES table and then create an email (with these two email
addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES and
EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls come
has an
ID field, which I'm not including in the query. In the Criteria
under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or
[Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator. In
the
Event Procedure for the Command Button (named COMPLETED) I have the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line for
EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO
NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER],
strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the
Origniator's
and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your
assistance!
Linda
 
M

Mark A. Sam

I think if you just sent me the form and subform, I could figure it out, but
not test it.


ADB_Seeker said:
Mark,
I posted a response, but don't see it so I'm posting again.
Thank you for all your help. Unfortunately at this time, I don't have a
small sample db that I can send. I will continue researching and working
with
it. I'm sure it is something simple that I'm overlooking.

Thank you for all your assistance and patience!

Best regards,
Linda

Mark A. Sam said:
Linda,

This is difficult to visualize in my head. If you have a small db, send
it
to me at
MarkASam***@***msn.com. Remove the Asterisks (*). If you have a
seperate
db for the data send that also and I'll look at it. When you send a
database either zip it or change the extention to .mdx (for version
2000-2003 databases) or accdx (for version 2007 databases).

God Bless,

Mark


ADB_Seeker said:
Thanks, Mark.
I will change my code to your suggestion for getting the email to send
twice, which will solve the semicoloon/space issue.

I'm not understanding how to get Access to look at the name in the
controls
[Requester] and [Originator] on the form, use this information to match
the
name in the Assignees Table and then pull the email addresses that
match
those names from column 3 in this table. I'm using a query to do this.

My challenge is to get the email address only in [TO] and not the name,
which for some reason is populating the [TO] area. I want the code to
look
at
the names in the form controls mentioned above and then select the
email
addresses associated with those names from a specific table and it's
not
working. So, I think my issue is with the code in the query and not the
SendObject, but I'm not 100% sure. I hope I've explained my delimma
better
this time.

Thank you for your patience and assistance!

:

Linda,

I think you are not understanding the Parameters for the SendFile
method:

docmd.SendObject
ObjectType,ObjectName,OutputFormat,[To],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

The Parameter [To] is for an email address only, not a name and email
address. I am not sure if you can specify multiple addresses
seperated
by
comma's, but I think not. What you can do is sent it twice like this:

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address1],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

docmd.SendObject ObjectType,ObjectName,OutputFormat,[Email
Address2],[CC],[Bcc],Subject,MessageText,EditMessage,TemplateFile

You can put the field name in instead of using the strToWhom variable.

I hope that makes sense.

God Bless,

Mark


Mark,
Thank you for your response. The email address is located in the
Assignee
Table (Column 3).
Originator is the name of the person the task is assigned to (I
know,
confusing-I didn't name it).
Requester is the person submitting the task for approval.
I need to send both of these people an email when the request is
approved
and want the code to look in the Originator and Requester Name
fields
to
get
their names, match them to the names in Column 2 of the Assignee
table,
and
then use their email addresses in column 3 of the Assignee Table to
send
one
email to both of them. Email addresses are usually separated by a
semicolon
and a space, which is why I was asking about how to put that in the
code.
Thank you for your help!

:

Linda,

This looks like a problem:

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]

Is me![Originator] the email address? If so change the line to

strToWhom = Me![ORIGINATOR]

I don't know if it will solve all of problems. I don't understand
about
the
two email addresses and the semi-colon.

God Bless,

Mark A. Sam

message
I've searched other posts and not found one that deals with my
specific
question. All help is appreciated.

I have a subform (named: ASSIGN RESOURCE BY DWG) that contains
two
controls
(ORIGINATOR & REQUESTERS NAME).
When I click on my Command Button (on the form) I want it to use
the
information from these two controls to get the email addresses
from
my
ASSIGNEES table and then create an email (with these two email
addresses).

I set up a query (ASSIGNEE-QUERY) that has two fields: ASSIGNEES
and
EMAIL
ADDRESS. The table (named: ASSIGNEES) from which these controls
come
has an
ID field, which I'm not including in the query. In the Criteria
under
ASSIGNEES, I put the following code:
[Forms]![ASSIGN RESOURCE BY DWG]![REQUESTERS NAME] Or
[Forms]![ASSIGN
RESOURCE BY DWG]![Combo115]

Combo115 is the name of the control on the form for Originator.
In
the
Event Procedure for the Command Button (named COMPLETED) I have
the
following code:

Private Sub sendemail_Click()

Dim strToWhom As String
Dim strMsgBody As String

strToWhom = Me![REQUESTERS NAME] & Me![ORIGINATOR]
strMsgBody = "Your ER is approved. Look in the subject line
for
EO
Number and associated ER Number."

DoCmd.SendObject , , , strToWhom, , , "ER REQUEST APPROVED-EO
NUMBER
IS:
" & Me![EO NUMBER] & " & ER NUMBER IS: " & Me![ER NUMBER],
strMsgBody,
True
DoCmd.Close

Exit_sendemail_Click:
Exit Sub

Err_sendemail_Click:
MsgBox Err.Description
Resume Exit_sendemail_Click

End Sub

All of this works, except the email addresses. I get the
Origniator's
and
Requester's names instead of the email addresses.
Also, I need a semicolon & space between the two email addresses
to
separate them on the "TO" line.

I am new to Access and vba code. Thank you in advance for your
assistance!
Linda
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top