내 MAPISend 코드가 손상된 것 같아서 이제 1,500개 이상의 MAPISend 행을 BLAT로 바꾸려고 합니다. 내 스크립트를 검색하고 MAPISend 구문을 찾는 방법이 있습니까?
"$MAPISEND_DIR/mapisend" -u "$EMAILADDRESS" -p $EMAILPW -r "$PAGERADDRESS" -s "오류 - 모든 파일을 찾을 수 없음" -m "오류"
그런 다음 새로운 BLAT 구문으로 전환합니다.
blat -to "$PAGERADDRESS" -s "오류 - 모든 파일을 찾을 수 없음" -body "error"
("$MAPISEND_DIR/mapisend" -u "$EMAILADDRESS" -p $EMAILPW) 같은 것은 (blat)로 바꿔야 한다고 생각합니다. blat로 시작하고 같은 줄에 -r이 있는 것은 -로 바꿔야 합니다. 그런 다음 blat로 시작하고 같은 줄에 -m이 있는 모든 항목은 -body로 이동해야 합니다.
답변1
내 문제를 해결하기 위해 vb.net에서 Windows 콘솔 응용 프로그램을 만들 수 있었습니다. 이것이 당신의 시간을 절약해주기를 바랍니다. 데이터베이스에 로그인한 다음 데이터베이스에서 이메일을 보냅니다. 로그 파일용 폴더도 생성해야 합니다. 암호:
Module MAPISend
'Convert Mapisend Message to Blat mapisend syntax -u "$EMAILADDRESS" -p $EMAILPW -r "[email protected]" -s "subject"
'-m "body " -t \\\\$SERV\\$SHARE\\data\\log\\Data.txt
'blat syntax "\\\\$SERV\\$SHARE\\data\\log\\ProcessData.log"
'-t "[email protected]" -s "subject" -body "body" -attach "\\\\$SERV\\$SHARE\\data\\log\\Data.xlsx" -b [email protected]
Public Sub Main(ByVal sArgs() As String)
On Error GoTo ErrHandler
Dim i As Integer = 0
Dim strAttachment As String = ""
Dim strBody As String = " "
Dim strBodyText As String = ""
Dim strEmailAddress As String = "[email protected]"
Dim strFileLocation As String = ""
Dim strPassword As String = ""
Dim strTo As String = "[email protected]"
Dim strSubject As String = "Test"
Dim strGUI As String = System.Guid.NewGuid.ToString()
Dim strHostName As String
Dim shell
Dim fso
Dim file
Dim text
strFileLocation = "c:\windows\"
strHostName = System.Net.Dns.GetHostName()
'Determine which parameter is being passed in then grab the data after found
While i < sArgs.Length 'So with each argument
Select Case sArgs(i)
Case "-u" 'if -u is being passed in
strEmailAddress = Replace(sArgs(i + 1), """", "") ' get the parameter after -u
i = i + 1
Case "-p"
strPassword = Replace(sArgs(i + 1), """", "")
i = i + 1
Case "-r"
strTo = Replace(Replace(sArgs(i + 1), ";", ","), """", "")
i = i + 1
Case "-s"
strSubject = Replace(sArgs(i + 1), """", "")
i = i + 1
Case "-m"
strBody = Replace(sArgs(i + 1), """", "")
If strBody = "" Then
strBody = " "
End If
i = i + 1
Case "-t"
strBodyText = Replace(sArgs(i + 1), """", "")
i = i + 1
Case "-f"
strAttachment = "-attach """ & Replace(sArgs(i + 1), """", "") & """"
i = i + 1
End Select
i = i + 1
End While
shell = CreateObject("WScript.Shell")
If strBodyText <> "" Then
'Call Shell script
shell.exec("""" & strFileLocation & "blat.exe"" """ & strBodyText & """ -t """ & strTo & """ -s """ & strSubject & """ -b ""[email protected]"" " & strAttachment & " -log ""C:\apps\mapisend\" & strGUI & ".txt"" -debug")
Console.WriteLine("""" & strFileLocation & "blat.exe"" """ & strBodyText & """ -t """ & strTo & """ -s """ & strSubject & """ -b ""[email protected]"" " & strAttachment & " -log ""C:\apps\mapisend\" & strGUI & ".txt"" -debug")
Else
shell.exec("""" & strFileLocation & "blat.exe"" -t """ & strTo & """ -s """ & strSubject & """ -body """ & strBody & """ -b ""[email protected]"" " & strAttachment & " -log ""C:\apps\mapisend\" & strGUI & ".txt"" -debug")
Console.WriteLine("""" & strFileLocation & "blat.exe"" -t """ & strTo & """ -s """ & strSubject & """ -body """ & strBody & """ -b ""[email protected]"" " & strAttachment & " -log ""C:\apps\mapisend\" & strGUI & ".txt"" -debug")
End If
'Wait for debug file to be generated
For i = 0 To 30
If My.Computer.FileSystem.FileExists("C:\apps\mapisend\" & strGUI & ".txt") Then
fso = CreateObject("Scripting.FileSystemObject")
file = fso.OpenTextFile("C:\apps\mapisend\" & strGUI & ".txt", 1)
text = file.ReadAll
Console.WriteLine(text)
'check if file is complete if not continue for i statement
If Not LCase(text) Like "*end of session*" Then
Threading.Thread.Sleep(1000)
Console.WriteLine("Waiting for \\" & strHostName & "\C$\apps\mapisend\" & strGUI & ".txt to generate end of session: " & i & " of 30")
Continue For
End If
'check if file is sent if not send error
If Not LCase(text) Like "*sending*" Or LCase(text) Like "*** warning ***" Then
LogError("\\" & strHostName & "\C$\apps\mapisend\" & strGUI & ".txt")
End If
file.Close()
Exit For
Else
Threading.Thread.Sleep(500)
Console.WriteLine(i)
End If
Next I
'Check if file was generated/completed within the 30 seconds
If i = 30 Then
LogError("Disk Latency Error: The file took more then 30 seconds to generate. \\" & strHostName & "\C$\apps\mapisend\" & strGUI & ".txt")
End If
Exit Sub
ErrHandler:
LogError(Err.Description)
Console.WriteLine("Error: " & Err.Description)
End Sub
로깅은 다음과 같습니다.
Public Sub LogError(strMessage As String)
Dim Conn1 As New ADODB.Connection
Dim RS1 As New ADODB.Recordset
Dim Cmd1 As New ADODB.Command
Dim SQLConnect As String
On Error GoTo ERR1
SQLConnect = "Provider=sqloledb;User ID=xxxxx;Password=xxxxx;" & _
"Data Source=SQL01; Database=DW; " & _
"Persist Security Info=False;"
Conn1.ConnectionString = SQLConnect
Conn1.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Conn1.Mode = ADODB.ConnectModeEnum.adModeReadWrite
Conn1.Open()
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "INSERT INTO [dbo].[dimLog]" & _
"([LogDateTime],[PackageName],[Recipients],[Message],[MessageDescription],[EmailFormat],[HasError],[EmailSent])" & _
"Values" & _
"(sysdatetime(),'mapisend','[email protected]','MAPISend - ERROR - (SYSTEMS) - MAPISend','File Location: c:\mapisend\' " & _
" + CHAR(13) + CHAR(10) + 'Log Info:' + CHAR(13)+CHAR(10) + '" + strMessage + " ','HTML',1,0)"
Cmd1.Execute()
Conn1.Close()
Conn1 = Nothing
Exit Sub
ERR1:
Console.WriteLine("Error: " & Err.Description)
End Sub
End Module