Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email to multiple names in a textbox 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
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?

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
 
Thanks Ph,

I figured out how to add others from you code.

I really, really appreicate your help with this!!!
 
Phv,

If you are still there I have another issue that involves
what we have been talking about. I have found out that I
have another field I need to pick up for this email. It is
called Materials Distribution. It is a ComboBox that
only has one name in it. The name is Kim Dees. Her
email address is abkdees@nmhg.com. How can I get
this added to the Email?

I tried a couple of things like:
Code:
If Forms!ECNBCNVIPfrm!ECNDetailfrm![Materials Distribution] = "Kim Dees" Then
toEmail1 = "abkdees@nmhg.com"
But that cut out the other code. I do not know where to
place it and was wondering if you had any ideas?

Thanks for everything!
 
Should I make this a new posting since it is a new issue?
 
toEmail1 = toEmail1 & "abkdees@nmhg.com"

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top