*MailMessage [#v9349602] com.sun.star.mail モジュールのサービスを利用するとメールクライアンとなしでメールが送信できます (実際にメールを送信するのは Python の smtplib)。 しかし、メールを送信するときに必要な com.sun.star.mail.MailMessage サービスが提供されておらず、自分で com.sun.star.mail.XMailMessage インターフェースを作成するひつようがあります。 Py-UNO ではサービスを作成できるわけです。しかし、OOo Basic ではインターフェースの代用として CreateUnoListener 関数で作成したリスナーを使用するとしても、Attribute の設定ができません。 というわけで、OOo Basic からも利用できる MailMessage サービスを作成します。 [[i87023>http://www.openoffice.org/issues/show_bug.cgi?id=87023]] によると本体で実装されることはないようです。 #contents **パッケージ [#dfdd0e2e] -パッケージ --&ref(MailMessage-0.0.1.oxt); -ドキュメント (mytools.mail.XMailMessage2 インターフェースの IDL リファレンス) --&ref(MailMessage_doc.zip); **OOo Basic での利用 [#c8900b92] OOo Basic から利用する方法です。[[OOoBasic/Generic/SendingMail]] 参照。 **作成 [#g22ade4f] com.sun.star.mail.MailMessage サービスの実装ですが、既存の com.sun.star.mail.XMailMessage インターフェースだけでは送信者のメールアドレス、送信者名などを設定するメソッドが不十分です。そこで新しくインターフェースを作成する必要があるので IDL ファイルを用意します。 サービス名は mytools.mail.MailMessage です。新たに作成するインターフェースも mytools.mail.XMailMessage2 です。 #code(idl){{ #ifndef __mytools_mail_XMailMessage2_idl__ #define __mytools_mail_XMailMessage2_idl__ #ifndef __com_sun_star_uno_XInterface_idl__ #include <com/sun/star/uno/XInterface.idl> #endif #ifndef __com_sun_star_datatransfer_XTransferable_idl__ #include <com/sun/star/datatransfer/XTransferable.idl> #endif module mytools { module mail { /// /** Additional interface for com.sun.star.mail.MailMessage service. */ published interface XMailMessage2 : com::sun::star::uno::XInterface { //------------------------------------------------------------------------- /** Get the sender address. @return Sender address of the mail. */ string getSenderAddress(); /** Set the sender address. @param Sender address of the mail. */ void setSenderAddress( [in] string aSenderAddress ); /** Get the sender name. @return Sender name of the mail. */ string getSenderName(); /** Set the sender name. @param aSenderName Sender name of the mail. */ void setSenderName( [in] string aSenderName ); /** Get the reply to address. @return Reply to address of the mail. */ string getReplyToAddress(); /** Set the reply to address. @param aReplyToAddress Reply to address of the mail. */ void setReplyToAddress( [in] string aReplyToAddress ); /** Get the subject. @return Subject of the mail. */ string getSubject(); /** Set the subject. @param aSubject Subject of the mail. */ void setSubject( [in] string aSubject ); /** Get the body. @return Message body of the mail. */ com::sun::star::datatransfer::XTransferable getBody(); /** Set the body. @param xTransferable Message body of the mail. */ void setBody( [in] com::sun::star::datatransfer::XTransferable xTransferable ); }; }; }; #endif }} **サービス [#d5a449e0] サービス本体は上記 IDL にしたがって com.sun.star.mail.XMailMessage インターフェースおよび mytools.mail.XMailMessage インターフェースを継承するクラスをサービスとして登録します。 |