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
options: Options
campaign_id: Option<String>
recipients: Vec<Recipient>
content: Content
Methods
impl Message
[src]
impl Message
pub fn new(sender_address: EmailAddress) -> Self
[src]
pub fn new(sender_address: EmailAddress) -> Self
create new message with sender emailAddress
pub fn with_options(sender_address: EmailAddress, options: Options) -> Self
[src]
pub fn with_options(sender_address: EmailAddress, options: Options) -> Self
create new message with sending options
pub fn add_recipient(&mut self, address: EmailAddress) -> &mut Self
[src]
pub fn add_recipient(&mut self, address: EmailAddress) -> &mut Self
add an address to recipient list this method can be called multiple times WARNING: it does not check for duplicates for now
pub fn set_subject(&mut self, subject: &str) -> &mut Self
[src]
pub fn set_subject(&mut self, subject: &str) -> &mut Self
pub fn set_options(&mut self, options: Options) -> &mut Self
[src]
pub fn set_options(&mut self, options: Options) -> &mut Self
pub fn set_html(&mut self, html: &str) -> &mut Self
[src]
pub fn set_html(&mut self, html: &str) -> &mut Self
pub fn set_text(&mut self, text: &str) -> &mut Self
[src]
pub fn set_text(&mut self, text: &str) -> &mut Self
pub fn set_campaign_id(&mut self, campaign_id: &str) -> &mut Self
[src]
pub fn set_campaign_id(&mut self, campaign_id: &str) -> &mut Self
Trait Implementations
impl Debug for Message
[src]
impl Debug for Message
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for Message
[src]
impl Default for Message