Error message with a script sending emails to multiple recipients.

Hi all,
I am very new with powershell scripting and I want to request your attention and help on this issue.
I am getting this error message "Send-MailMessage: An invalid character was found in the mail header: ','" given by this script:
Param (
[string]$Path = "C:\Temp\",
[string]$SMTPServer = "smtp.domain1.com",
[string]$From = "[email protected]",
[string[]]$To = "[email protected],[email protected]",
[string]$Subject = "New backup file"
$SMTPMessage = @{
To = $To
From = $From
Subject = "$Subject at $Path"
Smtpserver = $SMTPServer
$File = Get-ChildItem $Path | Where { $_.LastWriteTime -ge [datetime]::Now.AddHours(-6) }
If ($File)
{ $SMTPBody = "`nThe following files have recently been added/changed:`n`n"
$File | ForEach { $SMTPBody += "$($_.FullName)`n" }
Send-MailMessage @SMTPMessage -Body $SMTPBody
I found the ForEach() approach but when I put it inside I get an infinite loop.
Many thanks for any suggestions

[string[]]$To = "[email protected],[email protected]",
should be
[string[]]$To = @("[email protected]","[email protected]")

Similar Messages

  • Error while sending email to Multiple Recipients

    Hi,
    I am trying to send email to multiple recipients .It works fine if all the email-addresses are valid. If even one is invalid throws exception .I wish to send it all the valid addresses even if some are invalid as this email will be going to 3000 users some of them will be wrong addresses.
    Help is greatly appreciated.
    -ksg
    Exception thrown:
    Exception in SendEmail.setAddress as :javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 550 <[email protected]>... User unknown
    Here is the main piece of code:
    message.saveChanges();
    Transport transport = session.getTransport("smtp");
    transport.connect("myhost", "", "");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();

    Hi there,
    Well I find the easiest way is to use a comma delimited string with the following bit of code.
    msg.setRecipients(
    addrType,
    InternetAddress.parse(smtpAddress, false));
    addrType will be TO,CC or BCC
    smtpAddress is a comma delimited string that I get from the results of a SQL Select request (looks something like "[email protected],[email protected],....,....,...."
    The boolean false is to prevent the parse checking the validity of the SMTP addresses as I prefer to deal with this by letting the SMTP server tell me which addresses are no good.
    Hope this helps,
    SH

  • On OnPremise, Sending email to multiple recipients doesn't work with SendEmail method

    Hi,
    We are creating a site collection on OnPremise from App by using Sharepoint Client API's (16 version).
    After creation of site collection, we are sending an email to all site collection administrators. But we found that email is being sent to the only first person mentioned in the "To" list. For sending email we are using following method "Microsoft.SharePoint.Client.Utilities.Utility.SendEmail()".
    We tried different scenarios by passing alternately domain username and email address.
    Here are the findings for the different scenarios for the "To" field:
    1) "domain\user1; domain\user1" => sends email to first user
    2) "[email protected]; [email protected]" => sends email to both emails (at least shows in inbox To field, two occurances of email)
    3) "domain\user1; domain\user2" => sends email to first user
    4) "[email protected]; [email protected]" => sends email to first user
    Here is the code we are using:
                    EmailProperties properties = new EmailProperties();
                    properties.To = to.ToList();
                    if (cc != null)
                        properties.CC = cc;
                    properties.Subject = subject;
                    properties.Body = body;
                    Utility.SendEmail(context, properties);
                    context.ExecuteQuery();
    Please let us know what is going wrong here.
    Thanks in advance for your valuable inputs.
    Br,
    Shriram
    Shri07

    According to the R16 Admin preview guide;-
    "Send Email to Multiple Recipients
    Expression Builder is now linked to the email address text field that is presented when the Specific Email Address
    option is selected. Workflow administrators can enter multiple email addresses directly, or click the "fx" icon
    beside the field, and use Expression Builder to define expressions that evaluate to one or more email addresses.
    The benefit of this feature is that emails can be stored on any text field in the base record and multiple emails can
    be sent using one workflow action. "
    But how that works exactly is not clear, I have tried commas, semi-colons, spaces, apostrophes, doublequotes, to separate and try to establish the correct syntax without luck.
    Bob - Perhaps you can do some digging and find out the correct syntax for multiple addresses?

  • Can't send emails to multiple recipients any more?

    Yesterday I had to send an email to some 30 other people (I only do this occasionally).
    It refused to go and I received this error message:-
    I have several email accounts but each one was the same.
    At that time I could not even send single emails but incoming emails were unaffected.
    Later in the day I received this email from my ISP mail account.
    Your emails may be blocked – please confirm your alternate BT Yahoo! Mail addresses
    Dear Customer,
    You’ve received a ‘553’ error message because we’ve upgraded your BT Yahoo! Mail account security to help protect against ‘spoofing’ – when people use alternate email addresses to disguise the real sender, possibly to commit fraud.
    What you need to do
    We need you to take a few minutes to confirm each of the BT Yahoo! Mail alternate email addresses you use are genuine. If you don’t, you might get more ‘553’ error messages and have problems sending emails. Just log in and follow these simple steps. We don’t ask for any personal information.
    This is rubbish and I had a similar one last year which I ignored, as the simple steps were far from simple, and the following morning all was back to normal.
    So I ignored this email and tried again this morning.
    I was still unable to send emails to multiple recipients but now I can send single emails OK!
    Any ideas what is going on?
    Is it Mail's fault or my ISP's?

    From the error message, it looks like there was a problem with at least one of the addresses ("NONE"). It is possible that a bad address is in the list you tried to send to.
    I don't know anything about BT Internet, so I can't confirm the authenticity of the email you received.
    You should be able to log into your BT account directly from the web without using any links sent in the email.
    The email also seems to indicate you used an alias as the reply-to (from) email address.
    You didn't mask out the username for your smtp server and it is definitely different from the from account. This may all be normal, but it does tend to match what the email is telling you.

  • Question regarding sending email to multiple recipients

    Hi All,
    I am creating a workflow that will send an email notification everytime a new campaign is created. I've learned that R16 is capable of sending emails to multiple recipients, the only concern I have is I can't find any doumentation on how to do it. It is stated in the R16 Administrator Preview Guide that you can select 'Specific Email Address' and enter multiple email addresses directly, I tried to enter multiple email addresses separated by comma - [email protected],[email protected],[email protected] as an example, but it doesn't work and prompts me to enter a valid email address. Could anybody guide me on how to enter multiple email addresses once the 'Specific Email Address' is selected or how to do it in the expression builder to define the expression that will define the list of emails. I know that using group email addresses can be used as an alternative to this requirement but I hope theirs a way to do this with workflows.
    Thanks,
    Wayne

    According to the R16 Admin preview guide;-
    "Send Email to Multiple Recipients
    Expression Builder is now linked to the email address text field that is presented when the Specific Email Address
    option is selected. Workflow administrators can enter multiple email addresses directly, or click the "fx" icon
    beside the field, and use Expression Builder to define expressions that evaluate to one or more email addresses.
    The benefit of this feature is that emails can be stored on any text field in the base record and multiple emails can
    be sent using one workflow action. "
    But how that works exactly is not clear, I have tried commas, semi-colons, spaces, apostrophes, doublequotes, to separate and try to establish the correct syntax without luck.
    Bob - Perhaps you can do some digging and find out the correct syntax for multiple addresses?

  • How to send email to multiple recipients??

    Hello Experts,
    I got a requirement to send email to multiple recipients. How to approach it as am fairly new to Workflow??
    Thanks & Regards,
    Mohammed.

    Hi,
      Do you only want to send mail using workflow or there any other steps. Then you can directly write the code
    Search in scn you will find lot of post for that
    http://scn.sap.com/thread/3256691

  • TS3276 error message when trying to send email

    On my Apple Iphone 3G, using Rogers as a cell provider, when an email came in and I tried to reply to it, it came up with an error message " A copy of this email has been placed in your outbox. The senders (me) address "[email protected]" was rejected by the server."
    I have checked all the settings and they are exactly the same as those on my computer mail settings. I can receive mail but cannot reply to this email.

    First unlock your caps lock key. Typing in all caps is inappropriate in online forums (considered shouting) and is hard to read.
    iPhoto>Preferences>General. Select the email program or how you wish to email photos from iPhoto.
    (There is an iPhoto forum for iPhoto questions).

  • Action to send email for multiple recipients

    Hi gurus,
    Currently the user needs to send a email for multiples recipients according to the organization structure.
    For example:
    The user generates a complaint and the systems must notify by email the department responsible to solve this complaint, sending an email for all employees assigned into this organizational unit.
    How should I configure the action to send an email for the whole departament?
    Best Regards,
    Gabriel Santana

    HI Gabriel,
    Get the email ID's of all the recipents from orgunit using FMs <b>RH_STRUC_GET</b> and <b>BAPI_BUPA_ADDRESS_GETDETAIL</b> into internal table <b>et_mailid</b> and then using FM <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b>.
    For reference check the code below:
    <b>*i_message has contents of mail body</b>
    DATA:    g_sent_all(1) TYPE c,
             g_doc_data LIKE sodocchgi1,
      DATA:  i_message      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
             i_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
             i_receivers    LIKE somlreci1  OCCURS 0 WITH HEADER LINE.
    Fill the document data.
        g_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
        g_doc_data-obj_langu = sy-langu.
        g_doc_data-obj_name  = 'SAPRPT'.
        CONCATENATE g_sdltime0(2) ':' g_sdltime2(2) ':' g_sdltime+4(2) INTO g_time.
        CONCATENATE c_subject g_time INTO g_doc_data-obj_descr SEPARATED BY space.
        g_doc_data-sensitivty = 'F'.
    Describe the body of the message
    Information about structure of data tables
        CLEAR i_packing_list.
        REFRESH i_packing_list.
        i_packing_list-transf_bin = space.
        i_packing_list-head_start = 1.
        i_packing_list-head_num = 0.
        i_packing_list-body_start = 1.
        DESCRIBE TABLE i_message LINES i_packing_list-body_num.
        i_packing_list-doc_type = 'RAW'.
        APPEND i_packing_list.
    Add the recipients email address
        LOOP AT et_mailid.
          CLEAR i_receivers.
          i_receivers-receiver = et_mailid-email_id.
          i_receivers-rec_type = 'U'.
          i_receivers-com_type   = 'INT'.
          i_receivers-notif_del  = 'X'.
          i_receivers-notif_ndel = 'X'.
          APPEND i_receivers.
        ENDLOOP.
    Call the FM to post the message to SAPMAIL
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = g_doc_data
            put_in_outbox              = 'X'
            commit_work                = 'X'
          IMPORTING
            sent_to_all                = g_sent_all
          TABLES
            packing_list               = i_packing_list
            contents_txt               = i_message
            receivers                  = i_receivers
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.
    Regards,
    Amit
    *Always reward points for helpful answers
    Message was edited by:
            Amit Kumar

  • Send email to multiple recipients

    Hello,
    Does anybody know what the syntax is for sending email to multiple email addresses? Should the email addresses be separated by commas or semi-colons? I can't seem to find an example anywhere and what I've tried doesn't seem to be working, because when I flushed my mail queue, nothing sent out. I know it works with only one address.
    HTMLDB_MAIL.SEND(
    P_TO =>
    Thanks,
    Nora

    Hi nora
    to put multiple address you needs to put a comma between addresses .
    quote from htmldb documentation :
    "Valid e-mail address to which the e-mail will be sent (required).
    For multiple e-mail addresses, use a comma separated list."
    hope that help
    Zvika

  • Error Message While Trying to Send email from Mac Mail...

    hello. i have been following the discussion board from some time, and finally made my first mac purchase. only 3 days old.anyways, i am trying to send mail from my .mac email account. i paid for the 1 year subscription,so i know my subscription status is still up to date. however, when trying to send an email using the Mac Mail application,i get this error..
    Error
    This message could not be delivered and will remain in your Outbox until it can be delivered.
    the connection to the server "smtp.mac.com" on port 25 timed out.
    can someone help me?
    my isp is: Cox
    location: Virginia, USA
    just incase someone needed that. oh yes,i can also receive mail, but i just can not send any emails. i was trying to send an email to a "gmail" acct,and i also attached a 2mb pic.thank you to anyone who can assist me.

    This error message indicates your ISP blocks the use of SMTP servers that are outside of their network (or not provided by the ISP) on Port 25 which is the default/common port used by SMTP servers. Some ISPs allow the use of an authenticated SMTP server only that is outside of their network (such as the .Mac SMTP server) on Port 25 but some block its use regardless.
    These restrictions are in place as part of an overall effort to prevent spam emanating from the ISP's domain.
    Are you also accessing an email account with the Mail.app that is provided by Cox and if so, are you able to send messages with this account?
    Something to try.
    Go to Mail > Preferences > Accounts and under the Account Information tab for your .Mac account preferences at the SMTP server selection, select the Server Settings button for the .Mac SMTP server.
    Enter 587 in place of 25 in the Server Port field and when finished, select OK to save the changed setting.
    If this doesn't resolve it and you aren't accessing your Cox email account with the Mail.app, you need to create your Cox email account in Mail or at least add Cox's SMTP server and select/use Cox's SMTP server to send messages with your .Mac account which is invisible to all recipients.

  • Error message with Publisher attachments in emails.

    When trying to open an MS Publisher document that's an email attachment, I get the following error message:  "Adobe Reader could not open xxxx.pub because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded.)"
    In addition to Publisher, I have several other MS products installed -- and have no problem opening these documents when they are attached to an email.
    Please help!!!  Thanks.

    I do not know why the .pub file type is associated with Adobe Reader on your system.
    The easiest way to re-establish the correct file association is to reinstall or repair MS Publisher.  Or you can right-click on a xxx.pub file, then re-associate the file type manually with MS Publisher.

  • Error message with Action Script 2.0 file

    Hi,
    I am trying to edit an old flash file that uses Action Script 2.0. I am using CS6 and keep getting the following error message after publishing:
    Scene 1, Layer 'AS', Frame 1, Line 5, Column 29
    1067: Implicit coercion of a value of type int to an unrelated type String.
    Can you suggest any fixes or workarounds? I also have Flash 4.0. Can i downsave the file? If so, how?
    Thanks!

    Thank you. I think that did fix the original two errors. But now upon test of the file, I get some new errors:
    Symbol 'MoneySlider', Layer 'AS', Frame 1, Line 7, Column 3
    1120: Access of undefined property ratio.
    Symbol 'MoneySlider', Layer 'AS', Frame 1, Line 7, Column 20
    1180: Call to a possibly undefined method number.
    Symbol 'MoneySlider', Layer 'AS', Frame 1, Line 7, Column 27
    1120: Access of undefined property _root.
    Symbol 'MoneySlider', Layer 'AS', Frame 1, Line 9, Column 27
    1120: Access of undefined property ratio.
    And on the MoneySlide layer in Actions:
    this.ratio = 0;
    this.loadBar._width = 0;
    this.dragger.ratio.text= "$0";
    dragger.onPress=function(){
              this.startDrag(true,0,0,line._width,0);
              this.onEnterFrame=function(){
                        ratio=Math.round(number(_root.transitBenefitLimit/100)*(this._x/(line._width/10 0)));
                        loadBar._width = Math.round(this._x);
                        dragger.ratio.text= "$"+ratio;
    dragger.onRelease=dragger.onReleaseOutside=stopDrag;

  • Since upgrading to 31.0 I get the following error messages when composing and sending email: There was an error saving the message to Sent Mail and 1 more err

    The other error messages are "cannot copy message to drafts" and " thunderbird failed to connect to gmail server". This appears to only happen when sending mail to a gmail address.

    OK, you seem to be running Zone Alarm as your firewall. It includes a utility which checks to see whether a site is safe or not and also adds a plugin to Firefox which is listed as '''npFFApi'''. Can you disable that and see if it makes any difference?
    To get to the plugins manager, click the orange Firefox button, then click "Add-ons". In the page that opens, click the "Plugins" link on the left which will open the menu. Then find '''npFFApi '''and click the "''Disable''" button.

  • Unable to send emails to multiple recipients through oracle storedprocedure

    I have the email code working with single email in the To address but I am looping through the table and getting a semicolon separated emails and assining to_mail and I am unabl to send any emails to any users in To address but works for cc_address users. I am getting the following error in the stored procedure when compiling. Please help if any suggestions or any one came accross this issue. Thanks.
    ORA-29279: SMTP permanent error: 501 #5.1.1 bad address @abc.com
    ORA-06512: at "SYS.UTL_SMTP", line 29
    ORA-06512: at "SYS.UTL_SMTP", line 110
    ORA-06512: at "SYS.UTL_SMTP", line 252
    ORA-06512: at "abc_owner.SendMail", line 101
    ORA-06512: at line 10

    900045 wrote:
    I have the email code working with single email in the To address but I am looping through the table and getting a semicolon separated emails and assining to_mail and I am unabl to send any emails to any users in To address but works for cc_address users. I am getting the following error in the stored procedure when compiling. Please help if any suggestions or any one came accross this issue. Thanks.
    ORA-29279: SMTP permanent error: 501 #5.1.1 bad address @abc.com
    ORA-06512: at "SYS.UTL_SMTP", line 29
    ORA-06512: at "SYS.UTL_SMTP", line 110
    ORA-06512: at "SYS.UTL_SMTP", line 252
    ORA-06512: at "abc_owner.SendMail", line 101
    ORA-06512: at line 10when all else fails, Read The Fine Manual
    http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/u_smtp.htm#i1002798
    RCPT Function
    This subprogram specifies the recipient of an e-mail message.
    "To send a message to multiple recipients, call this routine multiple times. "
    "Each invocation schedules delivery to a single e-mail address."

  • Error message below appears when sending email. However,Email sends okay on second attempt.

    Tried compacting and clearing history, but neither worked.
    Sending of message failed. Unable to open the temporary file C:\Users\Terry\AppData\Local\Temp\nsmail.tmp. Check your 'Temporary Directory' setting.

    No, the article didn't seem to solve the problem.
    Of the three suggestions in the article, I was able to :
    1. Disable McAfee Anti-Spam Thunderbird Extension
    2. Disable email attachment scanning
    But unable to find in McAfee:
    3. Disable scanning of Thunderbird files and folders

Maybe you are looking for