none
Extract Message set in OOO using powershell

    Question

  • Hi All,

    I have a one-line script in my workflow which checks for AutoReply state set for a user and based on the response take an action.

    If the OutOfOffice is Enabled and Scheduled then i have been asked to get the message set and convert to a html file and to be sent to an email address.

    $OOOtext = Get-MailboxAutoReplyConfiguration -Identity 'SAMAccountName' | Select ExternalMessage

    $OOOtext | Out-File C:\Users\Location\User1.htm

    The above query does not work as it gives me a text ExternalMessage in the file.

    PLease advise how to take it further.


    Justin

    Wednesday, June 13, 2018 10:55 AM

Answers

  • Hi Justin,

    Try the following command and check again:

    $OOOtext | Export-Csv C:\Users\Location\User1.html -NoTypeInformation


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, June 14, 2018 8:58 AM
    Moderator

All replies

  • That property is a string.  In your script, you can wrap the string in whatever HTML you want.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    Wednesday, June 13, 2018 6:34 PM
  • Hi Justin,

    Try the following command and check again:

    $OOOtext | Export-Csv C:\Users\Location\User1.html -NoTypeInformation


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, June 14, 2018 8:58 AM
    Moderator
  • Hi Justin,

    I'm just writing to check how's everything going? If you have any questions or needed further help on this issue, please feel free to post back. If the issue has been resolved, please mark the helpful replies as answers, this will make answer searching in the forum easier and be beneficial to other community members as well. Thanks for your understanding.


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, June 21, 2018 9:56 AM
    Moderator
  • Really sorry Niko for not responding. My apologies. Below is the script that i have managed to put up with the help of the community.

    $FirstName = 'FN'
    $LastName = 'LN'
    $UserEmp = 'Identity'
    $To = "EMailaddress@doamain.com"
    $ExtMsgFile = "C:\$UserEmp.htm"
    $OOoConfig = Get-MailboxAutoReplyConfiguration -Identity $UserEmp
    $OOoConfig.ExternalMessage | Out-File $ExtMsgFile
    $BodyText = @"
    Hi Team,
    
    Please see attached the OutOfOffice Message of the user 
    
    FirstName : $FirstName
    LastName : $LastName
    EmpID : $UserEmp
    StartTime : $($OOoConfig.StartTime) 
    EndTime : $($OOoConfig.EndTime)
    "@
    
    $params = @{
        From = 'From address'
        To = $To
        Subject = 'Out Of Office Message of the user'
        SMTPServer = 'SMTP server'
        Attachments = $ExtMsgFile
        Body = $BodyText
    }
    Send-MailMessage @params


    Justin

    Thursday, June 21, 2018 11:42 AM