備忘録として
テンプレートファイルを利用してメール編集⇒下書き保存
・Outlookテンプレート(.oft)ファイルを使用
・メール作成後下書きに保存
・作成完了後に日付を入れてExcelを別名保存
FUNCTION Main_コピー GLOBAL
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
SET ExcelPath TO $'''C:\\RPA\\PAD\\Mail\\MailSetting.xlsx'''
SET OutlookAppPath TO $'''C:\\Program Files\\Microsoft Office\\root\\Office16\\OUTLOOK.EXE'''
SET OutlookTemplatePath TO $'''C:\\Users\\Chabudai_Gaeshi\\Downloads\\メールの下書き.oft'''
SET WorkFolder TO $'''C:\\RPA\\PAD\\Mail'''
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyyMMdd_HHmmss''' Result=> FormattedDateTime
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelPath Visible: True ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Setting'''
Excel.ReadFromExcel.ReadNamedCell Instance: ExcelInstance CellName: $'''SendList''' ReadAsText: False TrimEmptyCells: False RangeValue=> ExcelData
LOOP FOREACH CurrentItem IN ExcelData
IF CurrentItem[0] <> $'''#''' THEN
IF IsNotEmpty(CurrentItem[2]) THEN
System.RunApplication.RunApplicationAndWaitToLoad ApplicationPath: OutlookAppPath CommandLineArguments: $'''/t %OutlookTemplatePath%''' WorkingDirectory: WorkFolder WindowStyle: System.ProcessWindowStyle.Normal Timeout: 0 ProcessId=> AppProcessId
WAIT 1
DISABLE MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: WindowHandle TextToSend: $'''{Shift}({Tab})''' DelayBetweenKeystrokes: 30 SendTextAsHardwareKeys: False
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''%CurrentItem[2]%{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''%CurrentItem[3]%{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''%CurrentItem[4]%{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: CurrentItem[5] DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''{Control}({S}){Alt}({F4})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
Variables.ModifyDataTableItem DataTable: ExcelData ColumnNameOrIndex: 1 RowIndex: CurrentItem[0] Value: FormattedDateTime
END
END
END
LOOP FOREACH CurrentItem IN ExcelData
IF CurrentItem[0] <> $'''#''' THEN
IF CurrentItem[1] = FormattedDateTime THEN
Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: CurrentItem[1] Column: 2 Row: CurrentItem[0] + 1
END
END
END
Text.Replace Text: ExcelPath TextToFind: $'''.xlsx''' IsRegEx: False IgnoreCase: False ReplaceWith: $'''_%FormattedDateTime%.xlsx''' ActivateEscapeSequences: False Result=> ExcelSavePath
Excel.CloseExcel.CloseAndSaveAs Instance: ExcelInstance DocumentFormat: Excel.ExcelFormat.FromExtension DocumentPath: ExcelSavePath
END FUNCTION
テンプレートを使用せずメール作成
IF IsNotEmpty(CurrentItem[2]) THEN
Outlook.Launch Instance=> OutlookInstance
Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''chabudai.gaeshi@harapeko.com''' SendTo: CurrentItem[2] CC: CurrentItem[3] Subject: $'''%FormattedDateTime% %CurrentItem[4]%''' Body: CurrentItem[5] IsBodyHtml: False IsDraft: True
END