简体   繁体   English

如何使用Notes Java API在Domino服务器中发送带有附件的电子邮件?

[英]How to send an email with attachment in domino server using notes java api?

I have Java code to send email in domino server without attachment. 我有Java代码可以在没有附件的Domino服务器中发送电子邮件。 I want to get it working with attachments also. 我也想让它与附件一起使用。

try {
       Session dominoSession = NotesFactory.createSession( host, username, password );
       System.out.println("USER Detail : "+dominoSession.getUserName());
       Database dominoDb = dominoSession.getDatabase( host, mailbox );

       Document memo = dominoDb.createDocument();
       memo.appendItemValue( "Form", "Memo" );
       memo.appendItemValue( "Importance", "1" );
       memo.appendItemValue( "CopyTo", copyTo );
       memo.appendItemValue( "Subject", subject );
       memo.appendItemValue( "Body", message );
       memo.send( false, sendTo );

       dominoDb.recycle();
       dominoSession.recycle();
      }
      catch ( NotesException e )
      {
       System.out.println( "Error - " + e.toString() );
      }
      catch ( Exception e )
      {
       System.out.println( "Error - " + e.toString() );
      }

First of all, you should not use appendItemValue(). 首先,您不应使用appendItemValue()。 You use replaceItemValue() to insert data into text fields. 您可以使用replaceItemValue()将数据插入文本字段。

Second, the field 'body' is a rich text dfield. 其次,“ body”字段是富文本格式的dfield。 You need to use the methods and properties of the NotesRichTextItem class to work with rich text. 您需要使用NotesRichTextItem类的方法和属性来处理富文本格式。 Then you also have the ability to attach files. 然后,您还可以附加文件。 It is all described in the help file, with examples. 帮助文件和示例均对它进行了描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM