イベント作成:
1.最初に、Googleカレンダーを設定する必要があります-以下にその方法を示します。
2. VBScriptコードをvbsファイル(たとえば、google_sms.vbs)に保存します。
3.起動ライン:
cscript.exe google_sms.vbs "Googleアカウント名" "Googleアカウントパス" "テキストファイルへのパス"
Outlookの統合:
1.「ツール」-「マクロ」-「Visual Basic Editor」を開き、VbaProject.OTMプロジェクトでThisOutlookSessionを選択します。 SendNotificationSMS関数を挿入します。 指定する必要があるのは、ユーザー、パスワード、スクリプトへのパスです。
スクリプトに「署名」することをお勧めします(Visual Basic Editorでは、「ツール」-「デジタル署名...」)
2.ルール「ツール」-「ルールとアラート...」を作成し、「スクリプトの実行」アクションを選択します。 SendNotificationSMS関数を選択します。
3.Outlook2007。「ツール」-「マクロ」-「セキュリティ...」を開きます。 「すべてのマクロの警告」をインストールします。 Outlookを再起動します。 「マクロを無効にする」が有効になっているウィンドウが表示されたら、有効にします(通常、ルールが最初にトリガーされたとき、または「ツール」-「マクロ」-「Visual Basic Editor」を開いたときに表示されます)
4.すべてが機能することを確認します-たとえば、自分宛に電子メールを送信し、そのルールを呼び出す必要があります。
google_sms.vbs:
email = WScript.Arguments(0) passwd = WScript.Arguments(1) FileName = WScript.Arguments(2) ReminderMinutes = 10 DelayMinutes = 2 EventMinutes = 10 Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.OpenTextFile(FileName, 1, False) text = ts.ReadAll ts.Close text = Replace(text, vbCr, " ") text = Replace(text, vbLf, " ") text = Replace(text, vbCrLf, " ") text = Replace(text, ":", "-") BeginEntry = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gCal='http://schemas.google.com/gCal/2005'><content type=""html"">" ContentEntry = "</content><gCal:quickadd value=""true""/>" EndEntry = "</entry>" ReminderEntry ="<gd:reminder minutes='" + ReminderMinutes + "' method='sms'/>" authUrl = "https://www.google.com/accounts/ClientLogin" calendarUrl = "http://www.google.com/calendar/feeds/default/private/full" Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.open "POST", authUrl, FALSE objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.send "Email=" + email + "&Passwd=" + passwd + "&service=cl&source=Gulp-CalGulp-1.05" 'WScript.Echo objHTTP.status 'WScript.Echo "Headers:" + objHTTP.getAllResponseHeaders() strAuthTokens = objHTTP.responseText strAuthTokens = Replace(strAuthTokens, vbCr, "") strAuthTokens = Replace(strAuthTokens, vbLf, "") strAuthTokens = Replace(strAuthTokens, vbCrLf, "") strAuthTokens = Replace(strAuthTokens, "SID", "&SID", 1, 1) strAuthTokens = Replace(strAuthTokens, "LSID", "&LSID") strAuthTokens = Replace(strAuthTokens, "Auth", "&Auth") 'WScript.Echo strAuthTokens strAuthTokens = Right(strAuthTokens, Len(strAuthTokens)-Len("Auth=")-InStr(strAuthTokens, "Auth=")+1) 'WScript.Echo strAuthTokens Set objHTTP = Nothing Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.open "POST", calendarUrl, FALSE objHTTP.setRequestHeader "Content-Type", "application/atom+xml" objHTTP.setRequestHeader "Authorization", "GoogleLogin auth=" & strAuthTokens calendarEntry = "<entry xmlns='http://www.w3.org/2005/Atom'" _ & " xmlns:gd='http://schemas.google.com/g/2005'>" _ & "<category scheme='http://schemas.google.com/g/2005#kind'" _ & " term='http://schemas.google.com/g/2005#event'></category>" _ & "<title type='text'>" & "SMS" & "</title>" _ & "<content type='text'></content>" _ & "<gd:transparency" _ & " value='http://schemas.google.com/g/2005#event.opaque'>" _ & "</gd:transparency>" _ & "<gd:eventStatus" _ & " value='http://schemas.google.com/g/2005#event.confirmed'>" _ & "</gd:eventStatus>" _ & "<gd:where valueString='" & text & "'></gd:where>" _ dt = DateAdd( "n", ReminderMinutes + DelayMinutes, Now) objHTTP.send calendarEntry & "<gd:when startTime=" & GetDateTime(dt) & " endTime=" & GetDateTime(DateAdd("n", EventMinutes, dt)) & ">" & ReminderEntry & "</gd:when>" & EndEntry 'WScript.Echo objHTTP.status 'WScript.Echo "Headers:" + objHTTP.getAllResponseHeaders() strResponse = objHTTP.responseText 'WScript.Echo strResponse Function PadZero(value) PadZero = String(2 - Len(value), "0") & value End Function Function GetDateTime(value) GetDateTime = "'" & Year(value) & "-" & PadZero(Month(value)) & "-" & PadZero(Day(value)) & "T" & PadZero(Hour(value)) & ":" & PadZero(Minute(value)) & ":" & PadZero(Second(value)) & "'" End Function
email = WScript.Arguments(0) passwd = WScript.Arguments(1) FileName = WScript.Arguments(2) ReminderMinutes = 10 DelayMinutes = 2 EventMinutes = 10 Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.OpenTextFile(FileName, 1, False) text = ts.ReadAll ts.Close text = Replace(text, vbCr, " ") text = Replace(text, vbLf, " ") text = Replace(text, vbCrLf, " ") text = Replace(text, ":", "-") BeginEntry = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gCal='http://schemas.google.com/gCal/2005'><content type=""html"">" ContentEntry = "</content><gCal:quickadd value=""true""/>" EndEntry = "</entry>" ReminderEntry ="<gd:reminder minutes='" + ReminderMinutes + "' method='sms'/>" authUrl = "https://www.google.com/accounts/ClientLogin" calendarUrl = "http://www.google.com/calendar/feeds/default/private/full" Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.open "POST", authUrl, FALSE objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.send "Email=" + email + "&Passwd=" + passwd + "&service=cl&source=Gulp-CalGulp-1.05" 'WScript.Echo objHTTP.status 'WScript.Echo "Headers:" + objHTTP.getAllResponseHeaders() strAuthTokens = objHTTP.responseText strAuthTokens = Replace(strAuthTokens, vbCr, "") strAuthTokens = Replace(strAuthTokens, vbLf, "") strAuthTokens = Replace(strAuthTokens, vbCrLf, "") strAuthTokens = Replace(strAuthTokens, "SID", "&SID", 1, 1) strAuthTokens = Replace(strAuthTokens, "LSID", "&LSID") strAuthTokens = Replace(strAuthTokens, "Auth", "&Auth") 'WScript.Echo strAuthTokens strAuthTokens = Right(strAuthTokens, Len(strAuthTokens)-Len("Auth=")-InStr(strAuthTokens, "Auth=")+1) 'WScript.Echo strAuthTokens Set objHTTP = Nothing Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.open "POST", calendarUrl, FALSE objHTTP.setRequestHeader "Content-Type", "application/atom+xml" objHTTP.setRequestHeader "Authorization", "GoogleLogin auth=" & strAuthTokens calendarEntry = "<entry xmlns='http://www.w3.org/2005/Atom'" _ & " xmlns:gd='http://schemas.google.com/g/2005'>" _ & "<category scheme='http://schemas.google.com/g/2005#kind'" _ & " term='http://schemas.google.com/g/2005#event'></category>" _ & "<title type='text'>" & "SMS" & "</title>" _ & "<content type='text'></content>" _ & "<gd:transparency" _ & " value='http://schemas.google.com/g/2005#event.opaque'>" _ & "</gd:transparency>" _ & "<gd:eventStatus" _ & " value='http://schemas.google.com/g/2005#event.confirmed'>" _ & "</gd:eventStatus>" _ & "<gd:where valueString='" & text & "'></gd:where>" _ dt = DateAdd( "n", ReminderMinutes + DelayMinutes, Now) objHTTP.send calendarEntry & "<gd:when startTime=" & GetDateTime(dt) & " endTime=" & GetDateTime(DateAdd("n", EventMinutes, dt)) & ">" & ReminderEntry & "</gd:when>" & EndEntry 'WScript.Echo objHTTP.status 'WScript.Echo "Headers:" + objHTTP.getAllResponseHeaders() strResponse = objHTTP.responseText 'WScript.Echo strResponse Function PadZero(value) PadZero = String(2 - Len(value), "0") & value End Function Function GetDateTime(value) GetDateTime = "'" & Year(value) & "-" & PadZero(Month(value)) & "-" & PadZero(Day(value)) & "T" & PadZero(Hour(value)) & ":" & PadZero(Minute(value)) & ":" & PadZero(Second(value)) & "'" End Function
OutlookのVisual Basic Editor:
Sub SendNotificationSMS(MailItem As MailItem)
ユーザー= ""
パスワード= ""
テキスト= MyMail.Body
Set fso = CreateObject( "Scripting.FileSystemObject")
Set WshShell = CreateObject( "WScript.Shell")
Const TemporaryFolder = 2
TempFolder = fso.GetSpecialFolder(TemporaryFolder)
TempFile = TempFolder& "\"&fso.GetTempName()
ts = fso.OpenTextFile(TempFile、2、True)を設定します
ts.Write(テキスト)
ts.Close
WshShell.Run "cscript.exe"& "C:\ temp \ google_sms.vbs"& ""&ユーザー& ""&パスワード& ""&TempFile、2、True
fso.DeleteFile(TempFile)
終了サブ