list recipients in popup window

Welcome Forums General PowerShell Q&A list recipients in popup window

This topic contains 2 replies, has 3 voices, and was last updated by

 
Participant
9 months, 1 week ago.

  • Author
    Posts
  • #93481

    Participant
    Points: 0
    Rank: Member

    For a script i want to send an email with a attachement to different kind of users.

    I already have the following:

    $Sender = $emailaddress
    $SMTP = "outlook.office365.com"
    $Recipients = @("[firstname Lastname] ", "[firstname Lastname] ", "[firstname Lastname] ")
    $Subject = $Emailsubject
    $Body = $EmailMessage
    $Attachment = new-object Net.Mail.Attachment($fileLocation)
    

    Is it possible for recipient box i can create the smae i have for the $emailaddress
    that is:

    $Emailaddress = [microsoft.visualbasic.interaction]::inputbox('give up Email address','Emailaddress','...@campofriofg.com')
    

    But then that it is possible to imput multiple emailddresses ?

  • #93484

    Participant
    Points: 165
    Helping Hand
    Rank: Participant
  • #93486

    Participant
    Points: 0
    Rank: Member

    Would it perhaps be best to add in the description that users need to comma separate the email addresses? Then use a foreach loop to send the emails?

    eg.

    $EmailAddresses = $([microsoft.visualbasic.interaction]::inputbox('Provide email addresses, separated by commas','Emailaddress','...@campofriofg.com')).Split(",")
    
    foreach ($EmailAddress in $EmailAddresses)
    {
      *Email sending code*
    }

    Edit: in fact, as per Olaf Soyk's suggestion above, looks like Send-MailMessage would be able to accept $EmailAddresses (string array).

    $EmailAddresses = $([microsoft.visualbasic.interaction]::inputbox('Provide email addresses, separated by commas','Emailaddress','...@campofriofg.com')).Split(",")
    
    Send-MailMessage -To $EmailAddresses .... and so on.

The topic ‘list recipients in popup window’ is closed to new replies.