Newbie: Sending Mail

Hi All.

Im very new to Domino Designer.

Im trying to send an email to user after a user has filled out a request form.

Once the user has filled out the request form…they will need to click on the “Save and send request” button.

I have been looking at different ways of doing so and i have come across a sample code and have tried to adapt it to get it to work for my project, but nothing seems to happen…

Can someone please help me out??

I have created an action and input the following code…

On Error Goto ErrorHandler 'Start the error handler

Dim session As New NotesSession

Dim db As NotesDatabase



Dim docMemo As NotesDocument 'The mail memo

Dim rtitemBody As NotesRichTextItem 'Rich-text field to hold the Body





Set db = session.CurrentDatabase

Set docMemo = db.CreateDocument



docMemo.Form = "Memo"

docMemo.SendTo = pSendTo

docMemo.CopyTo = pCopyTo

docMemo.BlindCopyTo = pBlindCopyTo

docMemo.Subject = pSubject

Set rtitemBody = docMemo.CreateRichTextItem("Body")

Call rtitemBody.AppendText(pBody)

If Not(pDocLink Is Nothing) Then

	Call rtitemBody.AddNewLine(2)

	Call rtitemBody.AppendText({Click to open the document =>})

	Call rtitemBody.AppendDocLink(pDocLink, "Click to open the document")

End If

Call docMemo.Send(False)



fnSendMailWithDocLink = True

ErrorHandler:

'error occurred. 



'false, because an error occured

fnSendMailWithDocLink = False

I have then put the following code into my “save and send request button”

Dim ws As New NotesUIWorkSpace

Dim doc As NotesDocument

Dim arrSendTo(0 To 1) As String

Dim arrCopyTo(0 To 1) As String

Dim arrBlindCopyTo(0 To 1) As String

Dim txtSubject As String

Dim txtBody As String



Set doc = ws.CurrentDocument.Document



'Set mail memo fields

txtSubject = {This is a test e-mail}

txtBody = {Just testing the email...}

arrSendTo(0) = {user@hotmail.com}



arrCopyTo(0) = {user@hotmail.com}



arrBlindCopyTo(0) = {user@hotmail.co.uk}



'Try sending the mail

If fnSendMailWithDocLink(doc.memoarrSendTo, doc.memoarrCopyTo, doc.memoarrBlindCopyTo, txtSubject, txtBody,doc) Then

	'Success

Else

	'Failure	

End If

Any help will be grately apreciated…

Thanks

Subject: Sending Mail

You didn’t state what the problem was? I’m guessing your hotmail isn’t getting your e-mail based on the fact you have:

'Set mail memo fields

arrSendTo(0) = {user@hotmail.com}



arrCopyTo(0) = {user@hotmail.com}



arrBlindCopyTo(0) = {user@hotmail.co.uk}



'Try sending the mail

If fnSendMailWithDocLink(doc.memoarrSendTo, doc.memoarrCopyTo, doc.memoarrBlindCopyTo, txtSubject, txtBody,doc) Then

You’re setting arrSendTo, CopyTo and BlindCopyTo, yet you’re sending to doc.memoarrSendTo, CopyTo and BlindCopyTo.

Subject: RE: Sending Mail

Hi,

The problem is i want the form to save and then send notification to a user that a form has been completed and ideally would like a link in the email. At present, none of this happening…

I can write the code for saving the form…I’m just struggling on the code to send an email out to users.

I’ve taken the doc.memo away from…

f fnSendMailWithDocLink(arrSendTo, arrCopyTo, arrBlindCopyTo, txtSubject, txtBody,doc)

and the current error Im getting is…

“Type mismatch on: ARRSENDTO”

Any ideas?

Thanking you in advance

Subject: RE: Sending Mail

Well, now we need to see how the function is declared.

We are now passing it a string array vs the variant in the past.

I also assume you know that the doclink won’t work with hotmail, I assume you just changed the e-mail address to protect the “innocent.” :slight_smile:

Subject: RE: Sending Mail

BTW, just came across this in help… Just incase:

If the user’s notes.ini file includes the statement

NoExternalApps=1

then any formula involving @MailSend is disabled