Hallo,
ich möchte diesen Agenten nach Eingang neuer Mail oder periodisch starten. Manuell geht das. Aber automatisch geht nix:
Function SendToSms
Dim ws As New NotesUIWorkspace
Dim CurrentDb As NotesDatabase
Dim StrBody As String
Dim StrSubject As String
Dim DocsToDuplicate As NotesDocumentCollection
Dim Heute As NotesDateTime
Dim MyMime As NotesMIMEEntity
Dim MyBodyItem As NotesItem
Dim MySubjectItem As NotesItem
Dim CurrentDoc As NotesDocument
Dim iCount As Integer
Dim MyItem As NotesItem
Set CurrentDb = ws.CurrentDatabase.Database
Set DocsToSend = CurrentDb.UnprocessedDocuments
Set Heute = New NotesDateTime("")
Call Heute.SetNow
Set CurrentDoc = DocsToSend.GetFirstDocument
While Not CurrentDoc Is Nothing
On Error Goto SendError
Set MyBodyItem = CurrentDoc.GetFirstItem("Body")
Set MySubjectItem = CurrentDoc.GetFirstItem("Subject")
If Not MyBodyItem Is Nothing And Not MySubjectItem Is Nothing Then
If MyBodyItem.Type = MIME_PART Then
Set MyMime = MyBodyItem.GetMimeEntity
If Not MyMime Is Nothing Then
StrBody = MyMime.ContentAsText
End If ' Not MyMime Is Nothing
Else
StrBody = MyBodyItem.Text
End If ' MyBodyItem.Type = MIME_PART
StrSubject = MySubjectItem.Text
If Not Isnumeric(StrSubject) Then
Messagebox "ungültige Betreffzeile: " + StrSubject
Else
CurrentDoc.Sendto = StrSubject + "@xxxxxxx.xxxxx.xxx"
CurrentDoc.Subject = StrBody
Call CurrentDoc.Send(False)
Call CurrentDoc.ReplaceItemValue("SMSistSCHONgesendet","1")
Call CurrentDoc.ReplaceItemValue("PostedDate",Heute)
Call CurrentDoc.RemoveItem("DeliveredDate")
Call CurrentDoc.RemoveItem("ExcludeFromView")
Call CurrentDoc.Save(True, False)
End If
End If ' Not MyBodyItem Is Nothing And Not MySubjectItem Is Nothing Then
Set CurrentDoc = DocsToSend.GetNextDocument(CurrentDoc)
Goto weiter
SendError:
Messagebox Err(), "Error in Zeile : " + Str(Erl())
weiter:
Wend
End Function