2014-09-21 62 views
0


我想從xPages發送電子郵件。我創建了一個測試按鈕,添加一個簡單的動作「發送郵件」來了,但是當我點擊它發送測試電子郵件,我得到這個運行時錯誤:在xpages中發送MIME郵件運行時錯誤時出錯

Exception
Error sending MIME mail

我試圖用這個SSJS電子郵件發送太:

var doc:NotesDocument = database.createDocument(); 
doc.replaceItemValue("form", "Memo"); 
doc.replaceItemValue("sendTo", "[email protected]"); 
doc.replaceItemValue("subject", "hi there!"); 
doc.replaceItemValue("body", "content here"); 
doc.send(); 

,但我得到這個運行時錯誤:

Error while executing JavaScript action expression Script interpreter error, line=6, col=5: [TypeError] Exception occurred calling method NotesDocument.send() null

我會感謝你的幫助。
謝謝

+0

請在服務器上檢查您的XPages日誌文件以獲取錯誤背後的詳細信息,並告訴我們。爲便於訪問日誌文件,請使用OpenNTF的XPage日誌文件讀取器 – 2014-09-21 06:11:56

回答

0

我創建函數來發送郵件像下面的代碼:

function sendDocument(memsendto,memcopyto,memsubject,membody,memprincipal) { 
var memo:NotesDocument = database.createDocument(); 
var stream = session.createStream(); 
var body = memo.createMIMEEntity(); 
memo.replaceItemValue("Form","Memo"); 
if(memcopyto!=null) { 
    memo.replaceItemValue("CopyTo",memcopyto); 
} 
if(memprincipal!=null) { 
    memo.replaceItemValue("Principal",memprincipal); 
} 
memo.replaceItemValue("Subject",memsubject); 
memo.replaceItemValue("SendTo",memsendto); 
stream.writeText(membody); 
body.setContentFromText(stream, "text/html;charset=iso-8859-1",1729) 
memo.send();   
} 

你可以把功能上SSJS腳本Libary並加載它的XPages資源並使用它。希望這個功能可以解決你的問題。

0

對於那些希望使用它的人來說,OpenNTF Domino API有一個DominoEmail類,旨在使電子郵件的創建更容易。有一個簡單的兩行版本的一個基本的文本郵件:

DominoEmail myEmail = new DominoEmail(); 
myEmail.createSimpleEmail("[email protected]", "", "", "Demo Email", "This is a test email from the OpenNTF Domino API", "") 

參數爲對象toNames,對象ccNames,對象bccNames,絃樂主體,客體的身體,字符串發件人。收件人的對象可以是List,數組或電子郵件地址的逗號分隔字符串。 Body的Object可以是StringBuilder,String或MIMEEntity。

從理論上說,SSJS因爲這將是:

var myEmail:org.openntf.domino.email.DominoEmail = new org.openntf.domino.email.DominoEmail(); 
myEmail.createSimpleEmail("[email protected]", "", "", "Demo Email", "This is a test email from the OpenNTF Domino API", "") 

不過,我沒有測試過這一點,SSJS的轉換爲Java類的能力可能有點武斷。它可能需要new java.lang.String("[email protected]")