Mail Merge Automate through Powershell

Welcome Forums General PowerShell Q&A Mail Merge Automate through Powershell

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 1 month ago.

  • Author
  • #98599

    Topics: 5
    Replies: 10
    Points: 0
    Rank: Member

    I am trying this mail as an example

    $DataSource = "C:\mailmerge\users.csv"
    $EmailSubject = "How to Setup Email"

    Import-CSV $DataSource | Foreach-Object {
    $ol = New-Object -comObject Outlook.Application
    $Mail = $ol.CreateItem(0)
    $Mail.Subject = $EmailSubject
    $Mail.From = ""
    $Mail.To = "$($_."Name")"
    $Mail.HTMLBody = ""
    $Mail.HTMLBody += "$($_.FIRSTNAME) $($_.LASTNAME),"
    $Mail.HTMLBody += "The attached directions will guide you through setting up your email account. Your username and password are as follows:"
    $Mail.HTMLBody += "If you have any issues installing, please contact support"


    Foreach-Object : There must be at least one name or contact group in the To, Cc, or Bcc box.
    At line:4 char:27
    + Import-CSV $DataSource | Foreach-Object {
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [ForEach-Object], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.ForEachObjectCommand

    Whether the same can be done through SMTP without Authentication ?

  • #98601

    Topics: 1
    Replies: 1331
    Points: 1,679
    Helping Hand
    Rank: Community Hero

    Why don't you use the cmdlet made for sending mails Send-MailMessage?

The topic ‘Mail Merge Automate through Powershell’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort