+ Reply to Thread
Results 1 to 9 of 9

Send workbook via email to multiple recipients

Hybrid View

  1. #1
    Registered User
    Join Date
    11-20-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2007 Professional
    Posts
    20

    Send workbook via email to multiple recipients

    I am using the following code to try and send a workbook via attachment to multiple email recipients however it will not work. If I only include one recipient then the code runs fine however it crashes when there is more than one.

    Is anyone able to help me?

       ActiveWorkbook.SendMail _
        Recipients:="aaa@aaa.com.au", "bbb@bbb.com.au", "ccc@ccc.com.au", "ddd@ddd.com.au", _
        Subject:="Subject" & Format(Date, "yyyymmdd")
    Last edited by lethal; 11-23-2008 at 06:31 PM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening lethal
    Quote Originally Posted by lethal View Post
    I am using the following code to try and send a workbook via attachment to multiple email recipients however it will not work. If I only include one recipient then the code runs fine however it crashes when there is more than one.
    You just have to pass all the addresses to the mail client as a single string, the mail client will then parse them. Try this amendment :
    ActiveWorkbook.SendMail _
        Recipients:="aaa@aaa.com.au;bbb@bbb.com.au;ccc@ccc.com.au;ddd@ddd.com.au", _
        Subject:="Subject" & Format(Date, "yyyymmdd")
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    11-20-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2007 Professional
    Posts
    20
    Hi dominicb,

    I have adjust my code as follows:

    ActiveWorkbook.SendMail _  
    Recipients:=aaa@aaa.com.au;bbb@bbb.com.au;ccc@ccc.com.au;ddd@ddd.com.au", _
    Subject:="Subject" & Format(Date, "yyyymmdd")
    However I still get runtime error '1004': Unknown recipient name found in recipient list. Use a valid name and try again.

    Do you have any idea why I am getting this error?
    Last edited by lethal; 11-23-2008 at 11:35 PM.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi lethal

    You seem not to have opened your quotes.
    Try putting opening quotes in and rry again :

    ActiveWorkbook.SendMail _  
    Recipients:="aaa@aaa.com.au;bbb@bbb.com.au;ccc@ccc.com.au;ddd@ddd.com.au", _
    Subject:="Subject" & Format(Date, "yyyymmdd")
    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    11-20-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2007 Professional
    Posts
    20
    Quote Originally Posted by dominicb View Post
    Hi lethal

    You seem not to have opened your quotes.
    Try putting opening quotes in and rry again :

    ActiveWorkbook.SendMail _  
    Recipients:="aaa@aaa.com.au;bbb@bbb.com.au;ccc@ccc.com.au;ddd@ddd.com.au", _
    Subject:="Subject" & Format(Date, "yyyymmdd")
    HTH

    DominicB
    Hmm, I have no idea what I am doing wrong. I have the quotes in but I still get an error message.

    ActiveWorkbook.SendMail _
    Recipients:="aaa@aaa.com.au;bbb@bbb.com.au;ccc@ccc.com.au", _
    Subject:="Kogan Despatch Report eStore Logistics " & Format(Date, "yyyymmdd")
    Error message:

    Run time error '1004':

    This workbook contains features that are not supported by the file format that you selected. To avoid the possible loss of formatting or information, save a copy in the most recent Microsoft Excel Workbook format and resend it.

    This is very strange as I am able to send email with only one recipient. So far I have been running the code 3 times in a row to send to 3 different recipients.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Lethal,

    The recipients may need to be separated with commas instead of semi-colons depending on your default email client. Outlook uses semi-colons while Outlook Express uses commas.

    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    11-20-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2007 Professional
    Posts
    20
    From what I read on this page: http://www.ozgrid.com/forum/showthread.php?t=81023 it seems as though there is a bug with VB/Outlook. I have gotten over the issue by setting up a distribution list in Outlook 2007 and sending to the distribution list name from VB code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1