I have a textbox on my form. This texbox is populated from a Listbox. What I am trying to accomplish is the
following:
I want to tie an event to a button and when the button is clicked I would like for it to pull all the names from
the TextBox [Engineering Distribution] and have them become To: on a email ToEmail1. I think I know how
to do this with one name in the Textbox but I would like for it to add every name in the Textbox to the email.
The names are located in a Table FormEngMETbl The Full Name is in the EngME Field. The login
Name is in the [LoginName] field of the Table. If Allen Jackson is the Name in the TextBox, his login Name
would be abajacks. Each Name in the TextBox would have a LoginName. I would have to add @nmhg.com
to each LoginName. Again, I can do this with one name but do not know how to accomplish this with mulitple
names in the textbox. Can anyone help me accomplish this or does anyone have abetter idea on how to
do this?
following:
I want to tie an event to a button and when the button is clicked I would like for it to pull all the names from
the TextBox [Engineering Distribution] and have them become To: on a email ToEmail1. I think I know how
to do this with one name in the Textbox but I would like for it to add every name in the Textbox to the email.
The names are located in a Table FormEngMETbl The Full Name is in the EngME Field. The login
Name is in the [LoginName] field of the Table. If Allen Jackson is the Name in the TextBox, his login Name
would be abajacks. Each Name in the TextBox would have a LoginName. I would have to add @nmhg.com
to each LoginName. Again, I can do this with one name but do not know how to accomplish this with mulitple
names in the textbox. Can anyone help me accomplish this or does anyone have abetter idea on how to
do this?
Code:
Dim O As Outlook.Application
Dim m As Outlook.MailItem
Dim toEmail1 As String
Dim toEmail2 As String
Dim ccEmail1 As String
Dim ccEmail2 As String
Dim ccEmail3 As String
Dim bccEmail1 As String
Dim SL As String, DL As String
SL = vbNewLine
DL = SL & SL
Set O = CreateObject("Outlook.Application")
Set m = Outlook.CreateItem(0)
toEmail1 = ""
ccEmail1 = "abkkulhy@nmhg.com"
ccEmail2 = "abkkulhy@nmhg.com"
ccEmail3 = ""
bccEmail1 = "abajacks@nmhg.com"
m.To = toEmail1
m.CC = ""
m.BCC = bccEmail1
m.Subject = "Form #" & Forms!ECNBCNVIPfrm![ECNBCNVIP ID].Value & "; This ECN is ready for SOURCING"
m.Body = "This ECN is Ready for SOURCING." & DL & _
"Form # " & Forms!ECNBCNVIPfrm![ECNBCNVIP ID].Value & DL & _
"Thank you for your help" & DL & _
DLookup("ActualName", "ChangeFormUserNameTbl", "LoginName='" & GetCurrentUserName() & "'") & SL & _
"ECN Analyst"
m.Display
On Error GoTo Err_CloseForm_Click
DoCmd.Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub