[][src]Struct azure_functions::bindings::SendGridMessage

pub struct SendGridMessage {
    pub from: Option<EmailAddress>,
    pub subject: Option<String>,
    pub personalizations: Vec<Personalization>,
    pub contents: Vec<Content>,
    pub attachments: Vec<Attachment>,
    pub template_id: Option<String>,
    pub headers: HashMap<String, String>,
    pub sections: HashMap<String, String>,
    pub categories: Vec<String>,
    pub custom_args: HashMap<String, String>,
    pub send_at: Option<i64>,
    pub unsubscribe_group: Option<UnsubscribeGroup>,
    pub batch_id: Option<String>,
    pub ip_pool_name: Option<String>,
    pub mail_settings: Option<MailSettings>,
    pub tracking_settings: Option<TrackingSettings>,
    pub reply_to: Option<EmailAddress>,
}

Represents the SendGrid email message output binding.

The following binding attributes are supported:

NameDescription
api_keyThe name of an app setting that contains your API key. If not set, the default app setting name is "AzureWebJobsSendGridApiKey".
toThe default recipient's email address.
fromThe default sender's email address.
subjectThe default subject of the email.
textThe default email text content.

Examples

use azure_functions::{
    bindings::{HttpRequest, HttpResponse, SendGridMessage},
    func,
};

#[func]
#[binding(name = "output1", from = "azure.functions.for.rust@example.com")]
pub fn send_email(req: HttpRequest) -> (HttpResponse, SendGridMessage) {
    let params = req.query_params();

    (
        "The email was sent.".into(),
        SendGridMessage::build()
            .to(params.get("to").unwrap().as_str())
            .subject(params.get("subject").unwrap().as_str())
            .content(params.get("content").unwrap().as_str())
            .finish(),
    )
}

Fields

from: Option<EmailAddress>

The email address of the sender. If None, the from binding attribute is used.

subject: Option<String>

The subject of the email message. If None, the subject binding attribute is used.

personalizations: Vec<Personalization>

The list of personalized messages and their metadata.

contents: Vec<Content>

The list of email content.

attachments: Vec<Attachment>

The list of email attachments.

template_id: Option<String>

The id of the SendGrid template to use.

headers: HashMap<String, String>

The map of key-value pairs of header names and the value to substitute for them.

sections: HashMap<String, String>

The map of key-value pairs that define large blocks of content that can be inserted into your emails using substitution tags.

categories: Vec<String>

The list of category names for this message.

custom_args: HashMap<String, String>

The map of key-value pairs that are specific to the entire send that will be carried along with the email and its activity data.

send_at: Option<i64>

The unix timestamp that specifies when the email should be sent from SendGrid.

unsubscribe_group: Option<UnsubscribeGroup>

The associated unsubscribe group that specifies how to handle unsubscribes.

batch_id: Option<String>

The id that represents a batch of emails to be associated to each other for scheduling.

ip_pool_name: Option<String>

The IP pool that the message should be sent from.

mail_settings: Option<MailSettings>

The settings that specify how the email message should be handled.

tracking_settings: Option<TrackingSettings>

The settings that specify how the email message should be tracked.

reply_to: Option<EmailAddress>

The email address and name of the individual who should receive responses to the email message.

Methods

impl SendGridMessage[src]

pub fn build() -> MessageBuilder[src]

Creates a new MessageBuilder for building a SendGrid message.

Examples

use azure_functions::bindings::SendGridMessage;

let message = SendGridMessage::build()
    .to("foo@example.com")
    .subject("The subject of the message")
    .content("I hope this message finds you well.")
    .finish();

assert_eq!(message.personalizations[0].to[0].email, "foo@example.com");
assert_eq!(message.personalizations[0].subject, Some("The subject of the message".to_owned()));
assert_eq!(message.contents[0].value, "I hope this message finds you well.");

Trait Implementations

impl Clone for SendGridMessage[src]

impl Default for SendGridMessage[src]

impl Debug for SendGridMessage[src]

impl Serialize for SendGridMessage[src]

impl<'de> Deserialize<'de> for SendGridMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoRequest<T> for T[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,