multiple emails
I know this is a pretty old thread but I didn't want to start a new one. I have not touched VB since 2001.
I'm using Visual Studio 2008 - Visual Basic
I have an email textbox call MAIN_EMAILTextBox
A command button call bt_To
Another text box that is call tb_To
Another command button call bt_SendAllMail
I click on the command button "bt_To" and that gets me the email address's within "MAIN_EMAILTextBox". I can click on "bt_To" as many times I want and it'll enter in whatever email that is currently in "MAIN_EMAILTextBox".
The command button "bt_To" inserts the data into tb_To.
Example data that could be in the text box "tb_To" This field can contain many emails.
to_1@test.com;
to_2@test.com;
to_3@test.com
I click on the command button "bt_SendAllMail" and it will open up the default mail client (this is outlook) and insert those emails in ready for them to type in the subject.
My problem is that I can get it to work if the data is like this -
to_1@test.com,
to_2@test.com,
to_3@test.com
The differences is a comma "," instead of a semi-colon ";" .
But outlook requires the email to be separated by semi-colons instead of commas.
Codes:
--------------------------------------------
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_To.Click
If TabControl1.SelectedIndex() = 0 Then
Dim MainEmail As String = tb_To.Text
If (tb_To.Text <> "") Then
tb_To.Text = MainEmail + ", " + MAIN_EMAILTextBox.Text
Else
tb_To.Text = MAIN_EMAILTextBox.Text
End If
End If
End Sub
--------------------------------------------
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_SendAllMail.Click
If tb_To.Text = "" Then
MsgBox("You must enter an email addresses.")
Exit Sub
End If
'If IsValidEmail(tb_To.Text) = False Then
'MsgBox("Please enter a valid To: email address.")
'Exit Sub
'End If
EmailMessage.From = New MailAddress(Environment.UserName + "@test.com")
EmailMessage.To.Add(tb_To.Text)
Process.Start("Mailto:" + tb_To.Text)
End Sub
-------------------------------------------------
Outlook only works if the emails are separated by a ";" and not a ",".
Help?
I know about MailAddressCollection but I am not sure on how to code it in.
Thanks!!!