Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Set-PWDocumentState / Messaging services
    • Sign In

    • State Verified Answer
    • Replies 4 replies
    • Subscribers 65 subscribers
    • Views 1950 views
    • Users 0 members are here

    Set-PWDocumentState / Messaging services

    D.Widdifield
    Offline D.Widdifield over 5 years ago

    Is there a way to enable the messaging services to work when changing the state of a document via a powershell script? Changing the state manually triggers the messaging services to function, but when the state is changed using Set-PWDocumentState it does not.

    We were hoping this could work as part of some automation we are working on. The script works fine, it's a scheduled process but messaging is ignored. Looking for any ideas to enable some kind of notification to select staff.

    d

    • Sign in to reply
    • Cancel

    Top Replies

    • Kevin van Haaren
      Offline Kevin van Haaren Thu, Dec 7 2017 4:52 PM +2 verified
      would regular email work instead of projectwise messaging? PowerShell 5.1 has Send-MailMessage and the PSCX module has Send-SMTPMail. You could use that to send notifications from the script.
    • Kevin van Haaren
      +1 Offline Kevin van Haaren Thu, Dec 7 2017 4:52 PM

      would regular email work instead of projectwise messaging?  PowerShell 5.1 has Send-MailMessage and the PSCX module has Send-SMTPMail. You could use that to send notifications from the script.

       

      Answer Verified By: D.Widdifield 

      • Cancel
      • Vote Up +2 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • D.Widdifield
      0 Offline D.Widdifield Thu, Dec 7 2017 6:40 PM

      Just to follow up I have found a way with the help of someone to do all of this in Powershell. Basically have the powershell script flip the states and create the email!! Very cool stuff.

      d

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Dec 7 2017 7:42 PM in reply to D.Widdifield

      Feel free to share your script. It may help someone else.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • D.Widdifield
      0 Offline D.Widdifield Fri, Dec 8 2017 3:26 PM in reply to Brian Flaherty

      Here you go. Our need is to send an email to a specific user on a schedule, a list of any email that is in a predefined folder. We have email getting dumped directly into ProjectWise automatically. The user then moves the email as needed once notified. We run this every 2 hours. And yes most of this came from a fine Bentley systems engineer! Still tweaking the formatting but this works like a charm!

      d

      Add-Type -AssemblyName System.Web

      $Sourcefolder = "Folder\needed to process"

      ##Email Section
      $HTMLBody = @()
      $Header = @"
      <style>
      body { background-color:#FFFFFF;
      font-family:Tahoma;
      font-size:12pt; }
      h3, h4 {text-align:center;}
      td, th { border:1px solid black;
      border-collapse:collapse; }
      th { color:white;
      background-color:black; }
      table, tr, td, th { padding: 2px; margin: 0px }
      table { width:95%;margin-left:5px; margin-bottom:20px;}
      </style>
      "@
      $HTMLBody += $Header
      $HTMLBody += '<h3>ProjectWise Document Report</h3>'

      $HTMLBody += "<h4>Email currently in ProjectWise:</h4>"

      $HTMLBody += Get-PWDocumentsBySearch -FolderPath $SourceFolder -GetVersionsToo -JustThisFolder -GetAttributes -Slow | Select FileUpdateDate, OldDescription, OldName | ConvertTo-HTML -Property @{Label="Email Date"; Expression={$_.FileUpdateDate}},' ',@{Label="Email Description"; Expression={$_.OldDescription}},@{Label="Email Message"; Expression={$_.OldName}} | Out-String

      $HTMLBody = [System.Web.HttpUtility]::HtmlDecode($HTMLBody)

      Send-MailMessage -From "noreply@xxxx.ca" -To "xxxxxxx@xxxxxx.ca" -Subject "Email Report" -Body "$HTMLBody" -SmtpServer "smtp.xxxxx.ca" -BodyAsHTML

      Undo-PWLogin

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies