send-mailmessage

Hi can we get confirmation for sending mails in send-mailmessage, i tried it with $lastexitcode but it works only on ISE not in console, is there any other way of doing it?, basically i want to check whether the mail has been sent successfully


July 23rd, 2015 1:54am

Have the user reply to your message.

Of course you could take the lazy approach and read the help but that wouldn't be any fun.

Help Send-MailMessage -Full

Send-MailMessage -DeliveryNotificationOption OnSuccess

Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 2:15am

i have seen this but not sure how to make use of it
July 23rd, 2015 2:20am

$mailparam = @{
FROm = '<Address>'
To = '<Address>'
SMTP = '<SMTP>'
SUBJECT = 'Test Mail for - Mail Delivery Notification'
}
Send-MailMessage @mailparam -DeliveryNotificationOption OnSuccess 

help Send-MailMessage -Parameter DeliveryNotificationOption

-DeliveryNotificationOption <DeliveryNotificationOptions>
    Specifies the delivery notification options for the e-mail message. You can specify multiple values. "None" is the default value.  The alias for this
    parameter is "dno".
    
    The delivery notifications are sent in an e-mail message to the address specified in the value of the To parameter.
    
    Valid values are:
    
    -- None: No notification.
    
    -- OnSuccess: Notify if the delivery is successful.
    
    -- OnFailure: Notify if the delivery is unsuccessful.
    
    -- Delay: Notify if the delivery is delayed.
    
    -- Never: Never notify.
    
    Required?                    false
    Position?                    named
    Default value                "None"
    Accept pipeline input?       false
    Accept wildcard characters?  false
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 3:05am

This didnt solve my issue, as my qn was different. i have fixed it myself by $?
July 24th, 2015 4:47am

This didnt solve my issue, as my qn was different. i have fixed it myself by $?
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 8:46am

This didnt solve my issue, as my qn was different. i have fixed it myself by $?

So you are saying that you asked the wrong question.  Your question should have been how doo you detect an error has occurred in the send process and not how do you validate delivery. No error does not mean the mail was delivered.  It only means that Send-MailMessage was able to  hand the mail item to YOUR sending smtp server. This has nothing to do with mail "delivery".

Mail "confirmation" is a technical term that has nothing to do with errors in processing.  "$?" signal that no system errors have occurred.

How SMTP mail system work is an important technology for an Admin to know well.  I recommend that you spend some time studying this ooften used technology as you will need it frequently.

July 24th, 2015 9:16am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics