daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest May 16th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $olFolderInbox=6
  2. $oOutlook=New-Object -ComObject Outlook.Application
  3. $oNamespace=$oOutlook.GetNamespace("MAPI")
  4. $oFolder=$oNamespace.GetDefaultFolder($olFolderInbox)
  5.  
  6. $RedmineApiKey="<APIキー>"
  7. $RedmineUrl="<redmineのURL>/issues.xml?format=xml&key=$RedmineApiKey"
  8. $ProjectId=1 #プロジェクトID
  9. $TrackerId=1 #トラッカーID
  10.  
  11. foreach($oItem in $oFolder.Items)
  12. {
  13.     if(($oItem.Unread) -and ($oItem.SenderEmailAddress -like "*nakazawa@exbrain.jp*")){
  14.         $postBody  ="<?xml version=`"1.0`" encoding=`"UTF-8`"?>"
  15.         $postBody +="<issue>"
  16.         $postBody +="<project_id>$ProjectId</project_id>"
  17.         $postBody +="<tracker_id>$TrackerId</tracker_id>"
  18.         $postBody +="<subject>" + $oItem.Subject + "</subject>"
  19.         $postBody +="<description>" + $oItem.Body + "</description>"
  20.         $postBody +="<start_date>" + $oItem.ReceivedTime.ToString("yyyy-MM-dd") + "</start_date>"
  21.         $postBody +="<due_date>" + $oItem.ReceivedTime.addMonths(1).ToString("yyyy-MM-dd") + "</due_date>"
  22.         $postBody +="</issue>"
  23.  
  24.         Invoke-WebRequest -Uri $RedmineUrl -Method POST -ContentType "application/xml; charset=utf-8" -Body $postBody
  25.  
  26.         $oFolder1=$oFolder.Folders | ?{$_.name -match "フォルダ1"}
  27.         $oFolder2=$oFolder1.Folders | ?{$_.name -match "フォルダ2"}
  28.         $oItem.move($oFolder2)
  29.     }
  30. }
RAW Paste Data
Top