Reputation: 1
I am using a powershell script to send an email using:
$smtpClient = New-Object System.Net.Mail.SmtpClient
$smtpClient.Host = 'smtp.gmail.com'
$smtpClient.Port = 587
$smtpClient.EnableSsl = $true
$smtpClient.Credentials = [Net.NetworkCredential](Get-Credential GmailUserID)
$smtpClient.Send($emailMsg)
Where $emailMsg is setup as:
$emailMsg = New-Object System.Net.Mail.MailMessage
$emailMsg.From = $YourEmail
$emailMsg.To.Add($RecipientEmail)
$emailMsg.Subject = $Subject
$emailMsg.Body = $body
$emailMsg.Attachments.Add("$PSScriptRoot\$AttachmentFile")
What I really need to be able to do is send a follow up email that will be a reply to this initial message, is there a way to do this through powershell?
Upvotes: 0
Views: 3359
Reputation: 8775
You need to add a In-Reply-To
header to your SMTP message. The value of the header should be the same as the value of the Message-ID
header of the message that you wish to reply to.
$emailMsg.Headers.Add("In-Reply-To", "<[email protected]>")
More information can be found at Cognitive Buffet.
Upvotes: 1