1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| // start a Notes session
Domino.NotesSession session = new Domino.NotesSession();
session.Initialize(password);
// get the session user name
string userName = session.UserName; // something like "CN=Bertrand Rigal/OU=xxx/O=xxx"
string mailDbName = "names.nsf"; // default name used in my corpo
// open the mail database in Notes
Domino.NotesDatabase mailDb = session.GetDatabase("", mailDbName, false);
if (!mailDb.IsOpen)
{
mailDb.Open();
}
// set up the new mail document
Domino.NotesDocument mailDoc = mailDb.CreateDocument();
mailDoc.AppendItemValue("Form", "Memo");
mailDoc.AppendItemValue("Memo", "Memo");
mailDoc.AppendItemValue("SendTo", this._to.ToArray());
mailDoc.AppendItemValue("Recipients", this._to.ToArray());
mailDoc.AppendItemValue("CopyTo", this._cc.ToArray());
mailDoc.AppendItemValue("BlindCopyTo", this._bcc.ToArray());
mailDoc.AppendItemValue("From", userName);
mailDoc.AppendItemValue("Subject", subject);
mailDoc.AppendItemValue("DeliveryOption", "High");
mailDoc.AppendItemValue("DeliveryReport", "Basic");
mailDoc.AppendItemValue("ReturnReceipt", "No");
DateTime dt = DateTime.Now;
mailDoc.AppendItemValue("ComposedDate", dt);
mailDoc.AppendItemValue("PostedDate", dt);
mailDoc.AppendItemValue("Body", body);
mailDoc.SaveMessageOnSend = true;
// set up the embedded object and attachment and attach it
if (!attachment.Equals(""))
{
Domino.NotesRichTextItem attachMe = mailDoc.CreateRichTextItem("Attachment");
Domino.NotesEmbeddedObject embedObj = attachMe.EmbedObject(Domino.EMBED_TYPE.EMBED_ATTACHMENT, "", attachment, "Attachment");
}
// send the document
Object dummy = ""; // don't ask me why... it works !
mailDoc.Send(true, ref (Object)dummy); |
Partager