locked
Sending to multiple e-mail addresses from VB program RRS feed

  • Question

  • Hi,

     

    I've been trying to get my program to sent mails trough outlook. Its working fine except it will only sent to To/CC fields. I want it to sent the e-mail to 9/10 different addresses but when I add the same line a few times it will just sent to the first one. Can someone point me in the right direction? It isnt some spam program btw, its for informing staff about upcoming events:

     

       Dim objMail As Outlook.MailItem
            Try
                objMail = DirectCast(outlookApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
                objMail.Subject = NaamTextBox.Text
                objMail.To = E_mailTextBox.Text
                objMail.CC = E_mailTextBox1.Text

                objMail.Body = TextBox4.Text

                objMail.Send()
            
            Catch ex As Exception
                MessageBox.Show("Mails verstuurd")
            Finally
                objMail = Nothing
            End Try

     

    Thank you

    Sunday, December 19, 2010 6:48 PM

Answers

  • Hi PredatorJMK,

     

    Welcome to MSDN forums!

     

    According to your description of the problem, here are some codes for you try:

        objMail.Recipients.Add("address1@mail.com")

        objMail.Recipients.Add("address2@mail.com")

     

    I hope this will help to resolve your problemJ

     

    Best Regards, 


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 27, 2010 5:45 AM
    Moderator

All replies

  • Try to separate each e-mail-address by a semikolon (;)

    It's long time ago when I had this problem but i believe this solved it. Have a look to your outlool, when you start a new Mail the first e-mail-address will finished by ;

    Your Code:

    Dim objMail As Outlook.MailItem
            Try
                objMail = DirectCast(outlookApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
                objMail.Subject = NaamTextBox.Text
                objMail.To = E_mailTextBox.Text & ";"
                objMail.CC = E_mailTextBox1.Text & ";"

                objMail.Body = TextBox4.Text

                objMail.Send()
            
            Catch ex As Exception
                MessageBox.Show("Mails verstuurd")
            Finally
                objMail = Nothing
            End Try

     

    Good luck


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 Express
    • Proposed as answer by Heslacher Monday, December 20, 2010 11:08 AM
    Monday, December 20, 2010 10:59 AM
  • Hi PredatorJMK,

     

    Welcome to MSDN forums!

     

    According to your description of the problem, here are some codes for you try:

        objMail.Recipients.Add("address1@mail.com")

        objMail.Recipients.Add("address2@mail.com")

     

    I hope this will help to resolve your problemJ

     

    Best Regards, 


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 27, 2010 5:45 AM
    Moderator
  • Hey,

     

    I found almost the same solution, same idea! Thanks for the answers guys.

    Monday, December 27, 2010 9:13 PM
  • Hi PredatorJMK,

     

    It’s my pleasure!

    If you have any further problem, welcome to post in MSDN forumJ

     

    Best Regards,


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 28, 2010 1:12 AM
    Moderator