Requirement is , when a user sends mail based on the mail subject I need to call a url and then read response returned from that url and send the same to the sender on mail.
Plan is to create an agent and schedule it ‘After new mail arrives’
Not worked on urls before so unable to get any idea.
I am using a mail in database template and sending mail to mail in database id using the code below.
When I tried to call this on hotspot button without running / taking doc part and directly reading url and sending a response mail with reponse returned from url , this worked fine and I got response mail.
When I tried to run this on event ‘After new mail arrives’ this is not working - As per requirement this needs to run when new mail arrives.
When I did run this manually from designer -Right clicking and Run then I got a response mail and same works fine
Is there any other way I can implement this or any correction required in this code.
Any help is really appreciated.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim ritem As NotesRichTextItem
Dim vWinHTTP As Variant
Dim SMSAPIKey As String
Dim sMessage As String
Dim sURL As String
SMSAPIKey ="http://10.31.8.52/ABCotpweb/default.aspx"
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
If doc.subject(0)="TEST" Then
doc.Subject = "test response"
Set ritem = New NotesRichTextItem( doc, "Body")
Call ritem.AddNewLine( 1 )
Set vWinHTTP = CreateObject("WinHTTP.WinHTTPRequest.5.1")
Call vWinHTTP.SetProxy(HTTPREQUEST_PROXYSETTING_PROXY , "10.31.8.34:8080", "10.*")
Call vWinHTTP.Open( "GET", SMSAPIKey , False )
Call vWinHTTP.Send()
sResponse = vWinHTTP.ResponseText
Set vWinHTTP = Nothing
ritem.appendtext("Response is - "+sResponse )
'SendTo=doc.from(0)
Call doc.Send( False, "ABCD@in.xyz.com")
Set vWinHTTP = Nothing
End If
Call session.UpdateProcessedDoc( doc )
Set doc = collection.GetNextDocument(doc)
Wend
When I did run this manually from designer -Right clicking and Run then I got a response mail but when I tried opening that response mail I got error as ’ A stored form can not contain computed subforms’
You are calling docM.Send(True). The True argument specifies that you want to use the store-form-in-document feature. Why are you doing that? Why do you need to send a stored form? It looks like you are using the ordinary Memo form, which should already exist in everybody’s mailbox, so unless you have customized the form and you don’t want to update the mail template there’s no reason that I can think of for this.