[−][src]Struct sparkpost::transmission::Message
Represents email message including some mata-data
Example
use sparkpost::transmission::{Message, EmailAddress}; let mut email = Message::new(EmailAddress::new("marketing@example.sink.sparkpostmail.com", "Example Company")); email.add_recipient("wilma@example.sink.sparkpostmail.com") .campaign_id("postman_inline_both_example") .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'}}!");
deserialized json looks similar to this
{
"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
description: Option<String>
campaign_id: Option<String>
metadata: Option<Value>
substitution_data: Option<Value>
recipients: Recipients
Methods
impl Message
[src]
pub fn new<T: Into<EmailAddress>>(sender_address: T) -> Self
[src]
create new message with sender emailAddress
pub fn with_options(sender_address: EmailAddress, options: Options) -> Self
[src]
create new message with sending options
pub fn recipient_list(&mut self, list_name: &str) -> &mut Self
[src]
set an recipient list stored in the api replaces local recipients variable with a Sparkpost API list id
pub fn add_recipient<T: Into<Recipient>>(&mut self, recipient: T) -> &mut Self
[src]
add an address to recipient list
Recipient is replaced if they have same email address
pub fn subject<T: Into<String>>(&mut self, subject: T) -> &mut Self
[src]
set message subject
pub fn options<T: Into<Options>>(&mut self, options: T) -> &mut Self
[src]
set message options
pub fn html<T: Into<String>>(&mut self, html: T) -> &mut Self
[src]
set content html
pub fn text<T: Into<String>>(&mut self, text: T) -> &mut Self
[src]
set content text
pub fn campaign_id<T: Into<String>>(&mut self, campaign_id: T) -> &mut Self
[src]
set campaign id
pub fn template_id<T: Into<String>>(&mut self, template_id: T) -> &mut Self
[src]
set template id for content
pub fn substitution_data<T: Serialize>(&mut self, data: T) -> &mut Self
[src]
set substitution_dat
pub fn metadata<T: Serialize>(&mut self, data: T) -> &mut Self
[src]
set metadata
pub fn add_attachment<T: Into<Attachment>>(
&mut self,
attachment: T
) -> &mut Self
[src]
&mut self,
attachment: T
) -> &mut Self
adds attachment to Message, multiple attachments allowed
use sparkpost::transmission::{Message, Attachment}; let mut email = Message::new("marketing@example.sink.sparkpostmail.com"); let attachment = Attachment::from_data( "image.png", "image/png", "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAXxJREFUOBFjvJVg84P5718WBjLAX2bmPyxMf/+xMDH8YyZDPwPDXwYGJkIaOXTNGdiUtHAqI2jA/18/GUQzGsg3gMfKg4FVQo6BiYcPqyF4XcChaczA4+DP8P//f4b/P3+SZgAzvxCDSGYjAyMjI8PvZw+AoYXdLuyiQLtE0uoZWAREwLb+fnKXQTipkngXcJu7MnACQx8G2FX1GHgs3bDGBlYX8HlFM/z9+JbhzewWhmf1CQyfti9j+PfzBwO/ZxTMTDiNmQKBfmZX1GB42V/K8P38YbDCX/dvMDAwMzPwuYbBNcIYmC4AhfjvXwx/376AqQHTf96+ZPj34xuKGIiDaQBQ8PPBTQwCoZkMjJzcYA3MgqIMAr7xDJ/3rAHzkQnGO7FWf5gZ/qLmBSZmBoHgNAZee1+Gf18/MzCyczJ83LyQ4fPetch6Gf4xMP3FbgBMGdAgJqAr/n37zABMTTBROA0ygAWUJUG5Civ4B8xwX78CpbD6FJiHmf4AAFicbTMTr5jAAAAAAElFTkSuQmCC"); email.add_recipient("wilma@example.sink.sparkpostmail.com") .add_attachment(attachment);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,