Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

メッセージの送信

最後に、MessageText 引数を使用して、メソッドに渡すメッセージを記述します。

メッセージ・オブジェクトを渡すメールサーバ・オブジェクトの Send メソッドを呼び出して、メッセージを送信します。

—Utils.SendEmail—
Utils.SendEmail
ClassMethod SendEmail(Address As %String, MessageText As %String)
{
    // Create an SMTP object and connect to a server
    Set Mailer = ##class(%Net.SMTP).%New()

    // Fill in the name of your mail server
    Set Mailer.smtpserver = "**Server**"

    // Create a Message object and fill in From, To, Subject
    Set Msg = ##class(%Net.MailMessage).%New()
    Set Msg.From="**Address**"
    Do Msg.To.Insert(Address)
    Set Msg.Subject = "Theater Tickets"

    // Add message content
    Do Msg.TextData.Write(MessageText)
    // Send the message and close objects
    Do Mailer.Send(Msg)
    Quit
}
FeedbackOpens in a new tab