Struct sparkpost::Message[][src]

pub struct Message {
    pub options: Options,
    pub campaign_id: Option<String>,
    pub recipients: Vec<Recipient>,
    pub content: Content,
}

Represents email message including some mata-data

Example



use sparkpost::{Message, EmailAddress};

let mut email = Message::new(EmailAddress::with_name("marketing@example.sink.sparkpostmail.com", "Example Company"));
email.add_recipient("wilma@example.sink.sparkpostmail.com".into())
       .set_campaign_id("postman_inline_both_example")
       .set_subject("SparkPost inline template example")
       .set_html("<html><body>Here is your inline html, {{first_name or 'you great person'}}!<br></body></html>")
       .set_text("Here is your plain text, {{first_name or 'you great person'}}!");

deserialize to json structure to be sent over http

{
 "campaign_id": "postman_inline_both_example",
 "recipients": [
   {
     "address": {"email": "wilma@example.sink.sparkpostmail.com", "name": "Name"}
   }
 ],
 "content": {
   "from": {
     "email": "marketing@example.sink.sparkpostmail.com",
     "name": "Example Company"
   },

   "subject": "SparkPost inline template example",
   "html": "<html><body>Here is your inline html, {{first_name or 'you great person'}}!<br></body></html>",
   "text": "Here is your plain text, {{first_name or 'you great person'}}!"
 }
}

Fields

Methods

impl Message
[src]

create new message with sender emailAddress

create new message with sending options

add an address to recipient list this method can be called multiple times WARNING: it does not check for duplicates for now

Trait Implementations

impl Debug for Message
[src]

Formats the value using the given formatter. Read more

impl Default for Message
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Message

impl Sync for Message