Hello,
Today i encountered a problem about the notification to e-mail option in PRTG. We are currently using a service desk program that has a mail-import function. What we are trying to achieve that PRTG sends a notification by mail and that the service desk program automatically takes over the e-mail to escalate it to our service desk software. This is working all fine, but the problem is that i have to use multiple mail imports and the program uses it's information from the e-mail header of the PRTG notification e-mail.
Is it possible to change the e-mail header for every notification send by e-mail? The only setting i found was the main e-mail header which applies on every notification e-mail send by PRTG.
Article Comments
First of all thanks for your reply,
Yes this is possible but the most important criteria is the company name which takes it's information from the header/sender information that is send by PRTG.
We just wanted to know if it's possible to change this data but according to you it's unfortunately not possible. It's a answer to my question but i'm afraid that there is no solution.
Apr, 2014 - Permalink
You could create a custom notification to execute this PowerShell script to send notifications with custom header data (see Line 53). Alternatively you could look into the PRTG ticket system.
############################################################################## ## ## Send-MailMessage ## ## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) ## ## Illustrate the techniques used to send an email in PowerShell. ## In version two, use the Send-MailMessage cmdlet. ## ## Example: ## ## PS >$body = @" ## >> Hi from another satisfied customer of The PowerShell Cookbook! ## >> "@ ## >> ## PS >$to = "guide_feedback@leeholmes.com" ## PS >$subject = "Thanks for all of the scripts." ## PS >$mailHost = "mail.leeholmes.com" ## PS >Send-MailMessage $to $subject $body $mailHost ## ############################################################################## param( ## The recipient of the mail message [string[]] $To = $(throw "Please specify the destination mail address"), ## The subjecty of the message [string] $Subject = "<No Subject>", ## The body of the message [string] $Body = $(throw "Please specify the message content"), ## The SMTP host that will transmit the message [string] $SmtpHost = $(throw "Please specify a mail server."), ## The sender of the message [string] $From = "$($env:UserName)@example.com" ) ## Create the mail message $email = New-Object System.Net.Mail.MailMessage ## Populate its fields foreach($mailTo in $to) { $email.To.Add($mailTo) } $email.From = $from $email.Subject = $subject $email.Body = [string]::Format("{0}",$body); $email.Headers.Add("X-Company", "My Company"); ## Send the mail $client = New-Object System.Net.Mail.SmtpClient $smtpHost $client.UseDefaultCredentials = $true $client.Send($email)
The script has to be called with the following parameters:
.\mail.ps1 to@mail.com "My Subject" "Hello World" my.mailserver.com from@mail.com
Apr, 2014 - Permalink
Can you try the updated script? I modified the following line:
$email.Body = [string]::Format({0},$body);
...just to make sure that the double colon is escaped correctly.
Feb, 2016 - Permalink
Unfortunately it's not possible to set mail header options specifically for single notifications. Is it possible for your service desk program to filter by other criteria, i.e. mail subject?
Apr, 2014 - Permalink