pub struct SendGridMessage {Show 17 fields
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>,
}
Expand description
Represents the SendGrid email message output binding.
The following binding attributes are supported:
Name | Description |
---|---|
api_key | The name of an app setting that contains your API key. If not set, the default app setting name is “AzureWebJobsSendGridApiKey”. |
to | The default recipient’s email address. |
from | The default sender’s email address. |
subject | The default subject of the email. |
text | The 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.
Implementations§
Source§impl SendGridMessage
impl SendGridMessage
Sourcepub fn build() -> MessageBuilder
pub fn build() -> MessageBuilder
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§
Source§impl Clone for SendGridMessage
impl Clone for SendGridMessage
Source§fn clone(&self) -> SendGridMessage
fn clone(&self) -> SendGridMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SendGridMessage
impl Debug for SendGridMessage
Source§impl Default for SendGridMessage
impl Default for SendGridMessage
Source§fn default() -> SendGridMessage
fn default() -> SendGridMessage
Source§impl<'de> Deserialize<'de> for SendGridMessage
impl<'de> Deserialize<'de> for SendGridMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SendGridMessage
impl RefUnwindSafe for SendGridMessage
impl Send for SendGridMessage
impl Sync for SendGridMessage
impl Unpin for SendGridMessage
impl UnwindSafe for SendGridMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request