文書をメール送信します。
send(recipient:string) : void
send(recipients:java.util.Vector) : void
send(attachform:boolean) : void
send(attachform:boolean, recipient:string) : void
send(attachform:boolean, recipients:java.util.Vector) : void
パラメータ | 説明 |
---|---|
recipient | 文書の受信者 (1 つ)。下記を参照してください。 |
recipients | String 型の要素のベクトル。文書の受信者 (複数)。下記を参照してください。 |
attachform | true を指定すると、フォームが格納され、文書と共に送信されます。false (デフォルト) を指定すると、フォームは送信されません。計算されたサブフォームを使用するフォームは添付しないでください。 |
データベースに対して [読者] のアクセス権しかない場合、文書を作成して送信するエージェントは実行できますが、その文書にファイルを添付するとエージェントは機能しません。
IsSaveMessageOnSend プロパティは、送信済み文書をデータベースに保存するかどうかを制御します。IsSaveMessageOnSend プロパティが true で、文書にフォームが添付してある場合は、フォームは文書とともに保存されます。
フォームを送信すると文書のサイズが大きくなりますが、受信者は確実に文書のすべてのアイテムを見ることができます。
プログラムがワークステーションで実行されている場合、メール済み文書の From アイテムには現在のユーザーの名前が含まれます。プログラムがサーバー上でエージェントとして実行されている場合は、メール送信済み文書の From アイテムにはサーバー名が含まれます。
try {
// requestScope.sendto is a list box allowing multiple entries - returns java.util.ArrayList
// stop processing if sendto is empty
if (requestScope.sendto.isEmpty()) {
requestScope.status = "No sender(s) specified";
return;
}
var sendto = new java.util.Vector(requestScope.sendto);
var memo:NotesDocument = database.createDocument();
memo.appendItemValue("Form", "Memo");
// requestScope.subject is an edit box - returns string
memo.appendItemValue("Subject", requestScope.subject);
// requestScope.body is rich text - returns com.ibm.xsp.http.MimeMultipart
// do not create mime entity if body is null
if (requestScope.body != null) {
// stream html from body to mime entity
session.setConvertMime(false);
var stream = session.createStream();
stream.writeText(requestScope.body.getHTML());
var body = memo.createMIMEEntity("Body");
body.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
stream.close();
memo.closeMIMEEntities(true);
session.setConvertMime(true);
}
// set mail options
var items = memo.getItems(); // hack: encrypted and signed memo fails without this
memo.setEncryptOnSend(sessionScope.encrypt); // sessionScope.encrypt set by button
memo.setSignOnSend(sessionScope.sign); // sessionScope.sign set by button
memo.setSaveMessageOnSend(sessionScope.sos); // sessionScope.sos set by button
// send memo and report status
memo.send(false, sendto); // same as memo.send(sendto);
requestScope.status = "Message sent¥n";
requestScope.status +=
"Memo is " + (memo.isSaveMessageOnSend() ? "saved¥n" : "not saved¥n");
requestScope.status +=
"Memo is " + (memo.isEncryptOnSend() ? "encrypted¥n" : "not encrypted¥n");
requestScope.status +=
"Memo is " + (memo.isSignOnSend() ? "signed¥n" : "not signed");
} catch(e) {
requestScope.status = e.toString();
}
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.afterPageLoad><![CDATA[#{javascript:sessionScope.sos = false;
sessionScope.encrypt = false;
sessionScope.sign = false}]]></xp:this.afterPageLoad>
<xp:listBox id="listBox1" multiple="true" value="#{requestScope.sendto}">
<xp:selectItem itemLabel="Roberta Person/Acme"></xp:selectItem>
<xp:selectItem itemLabel="John Smith/Acme"></xp:selectItem>
<xp:selectItem itemLabel="Jane Brown/Acme"></xp:selectItem>
</xp:listBox>
<xp:br></xp:br>
<xp:inputText id="inputText1" value="#{requestScope.subject}"></xp:inputText>
<=subject
<xp:button id="button1" value="send">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:try {
// requestScope.sendto is a list box allowing multiple entries - returns java.util.ArrayList
// stop processing if sendto is empty
if (requestScope.sendto.isEmpty()) {
requestScope.status = "No sender(s) specified";
return;
}
var sendto = new java.util.Vector(requestScope.sendto);
var memo:NotesDocument = database.createDocument();
memo.appendItemValue("Form", "Memo");
// requestScope.subject is an edit box - returns string
memo.appendItemValue("Subject", requestScope.subject);
// requestScope.body is rich text - returns com.ibm.xsp.http.MimeMultipart
// do not create mime entity if body is null
if (requestScope.body != null) {
// stream html from body to mime entity
session.setConvertMime(false);
var stream = session.createStream();
stream.writeText(requestScope.body.getHTML());
var body = memo.createMIMEEntity("Body");
body.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
stream.close();
memo.closeMIMEEntities(true);
session.setConvertMime(true);
}
// set mail options
var items = memo.getItems(); // hack: encrypted and signed memo fails without this
memo.setEncryptOnSend(sessionScope.encrypt); // sessionScope.encrypt set by button
memo.setSignOnSend(sessionScope.sign); // sessionScope.sign set by button
memo.setSaveMessageOnSend(sessionScope.sos); // sessionScope.sos set by button
// send memo and report status
memo.send(false, sendto); // same as memo.send(sendto);
requestScope.status = "Message sent¥n";
requestScope.status +=
"Memo is " + (memo.isSaveMessageOnSend() ? "saved¥n" : "not saved¥n");
requestScope.status +=
"Memo is " + (memo.isEncryptOnSend() ? "encrypted¥n" : "not encrypted¥n");
requestScope.status +=
"Memo is " + (memo.isSignOnSend() ? "signed¥n" : "not signed");
} catch(e) {
requestScope.status = e.toString();
}}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:button id="button2"><xp:this.value><![CDATA[#{javascript:if (sessionScope.sos) {
return "Save on send"
} else {
return "Do not save on send"
}}]]></xp:this.value>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="button2">
<xp:this.action><![CDATA[#{javascript:if (sessionScope.sos) {
sessionScope.sos = false;
} else {
sessionScope.sos = true;
}}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:button id="button3"><xp:this.value><![CDATA[#{javascript:if (sessionScope.encrypt) {
return "Encrypt on send"
} else {
return "Do not encrypt on send"
}}]]></xp:this.value>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="button3">
<xp:this.action><![CDATA[#{javascript:if (sessionScope.encrypt) {
sessionScope.encrypt = false;
} else {
sessionScope.encrypt = true;
}}]]></xp:this.action>
</xp:eventHandler></xp:button><xp:button id="button4"><xp:this.value><![CDATA[#{javascript:if (sessionScope.sign) {
return "Sign on send"
} else {
return "Do not sign on send"
}}]]></xp:this.value>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="button4">
<xp:this.action><![CDATA[#{javascript:if (sessionScope.sign) {
sessionScope.sign = false;
} else {
sessionScope.sign = true;
}}]]></xp:this.action>
</xp:eventHandler></xp:button><xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:inputRichText id="inputRichText1" value="#{requestScope.body}"
style="height:148.0px;width:456.0px">
</xp:inputRichText>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:inputTextarea id="inputTextarea1" style="width:456.0px" value="#{requestScope.status}"></xp:inputTextarea><xp:br></xp:br>
</xp:view>