Wednesday, February 11, 2009

Sending an email from an Xpage, should it be this painfull?

here is the serverside script i run to send the email from a button, wouldnt it be great to be able to use @mailsend and return a http link? The plus side is i can put in html content this way and format it to my hearts content.

db1 = session.getDatabase("notes1/rcc","Applications\\database.nsf")
doc1 = db1.createDocument()
doc1.appendItemValue("Form","Memo")

var1 = "Employee: " + @Text(dominoDocument1.getItemValueString('employeename'))

var2 = "Craft: " + dominoDocument1.getItemValueString('craft')

var3 = "html tags" +
var1 + "breaktag" +
var2 + "breaktag" +
"a reflink tag + link " +
dominoDocument1.getDocument().getUniversalID()+"'> Link
"

+ "close html tags"



body = doc1.createMIMEEntity()
subject = body.createHeader("Subject")
subject.setHeaderVal("subject")

stream = session.createStream()
stream.writeText(var3)


body.setContentFromText(stream, "text/html; charset=iso-8859-1", 0)

doc1.send("group or persons name")

2 comments:

Anonymous said...

Is there anyway to specify who the email is from instead of who is logged into the form?

I'm currently working on an XPage that submits Contracts for review and would like it to be sent from CONTRACTREVIEW@example.com.

Anonymous said...

As a beginner in xpages, this script was a great help. Thanks Mark!

For something fairly common in apps with workflow, I would have thought there would be an @mailsend equivalent for xpages?

Anyway, I'm achieving what I'm after so all good!, and yes, being able to format the content with html is a bonus.

Post a Comment