@@ -66,8 +66,13 @@ encouraged to set ``raise_errors`` to ``True`` for forwards compatibility.
6666
6767``SendGridError `` is a base-class for all SendGrid-related exceptions.
6868
69- Adding Recipients
70- ~~~~~~~~~~~~~~~~~
69+ Methods
70+ ~~~~~~~
71+
72+ There are multiple ways to add recipients:
73+
74+ add_to
75+ ^^^^^^
7176
7277.. code :: python
7378
@@ -77,76 +82,118 @@ Adding Recipients
7782 message.add_to(' Example Dude <example@email.com>' )
7883 # or
7984 message.add_to([' Example Dude <example@email.com>' , ' john@email.com' ])
85+
86+ add_to_name
87+ ^^^^^^^^^^^
88+
89+ .. code :: python
90+
91+ message = sendgrid.Mail()
92+ message.add_to(' example@email.com' )
93+ message.add_to_name(' Example Dude' )
94+
95+ add_cc
96+ ^^^^^^
97+
98+ .. code :: python
8099
81- Adding BCC Recipients
82- ~~~~~~~~~~~~~~~~~~~~~
100+ message = sendgrid.Mail()
101+ message.add_cc(' example@email.com' )
102+ message.add_cc([' example@email.com' , ' john@email.com' ])
103+
104+ add_bcc
105+ ^^^^^^^
83106
84107.. code :: python
85108
86109 message = sendgrid.Mail()
87110 message.add_bcc(' example@email.com' )
88111 # or
89112 message.add_bcc([' Example Dude <example@email.com>' , ' john@email.com' ])
90-
91- Setting the Subject
92- ~~~~~~~~~~~~~~~~~~~
113+
114+ set_from
115+ ^^^^^^^^
93116
94117.. code :: python
95118
96119 message = sendgrid.Mail()
97- message.set_subject( ' Example ' )
120+ message.set_from( ' example@email.com ' )
98121
99- Set Text or HTML
100- ~~~~~~~~~~~~~~~~
122+ set_from_name
123+ ^^^^^^^^^^^^^
101124
102125.. code :: python
103126
104127 message = sendgrid.Mail()
105- message.set_text(' Body' )
106- # or
107- message.set_html(' <html><body>Stuff, you know?</body></html>' )
128+ message.set_from(' example@email.com' )
129+ message.set_from_name(' Example Dude' )
108130
109- Set From
110- ~~~~~~~~
131+ set_replyto
132+ ^^^^^^^^^^^
111133
112134.. code :: python
113135
114- message = sendgrid.Mail()
115- message.set_from (' example@email.com' )
136+ message. sendgrid.Mail()
137+ message.set_replyto (' example@email.com' )
116138
117- Set ReplyTo
118- ~~~~~~~~~~~
139+ set_subject
140+ ^^^^^^^^^^^
119141
120142.. code :: python
121143
122- message. sendgrid.Mail()
123- message.set_replyto( ' example@email.com ' )
144+ message = sendgrid.Mail()
145+ message.set_subject( ' Example ' )
124146
147+ set_text
148+ ^^^^^^^^
125149
126- Using Templates
127- ~~~~~~~~~~~~~~~~~
150+ .. code :: python
151+
152+ message = sendgrid.Mail()
153+ message.set_text(' Body' )
154+
155+ set_html
156+ ^^^^^^^^
128157
129158.. code :: python
130159
131- # template should be active
132- message.add_filter(' templates' , ' template_id' , ' TEMPLATE-ALPHA-NUMERIC-ID' )
160+ message = sendgrid.Mail()
161+ message.set_html(' <html><body>Stuff, you know?</body></html>' )
162+
163+ set_date
164+ ^^^^^^^^
133165
166+ .. code :: python
167+
168+ message = sendgrid.Mail()
169+ message.set_date(' Wed, 17 Dec 2014 19:21:16 +0000' )
134170
135171 Set File Attachments
136172~~~~~~~~~~~~~~~~~~~~
137173
174+ There are multiple ways to work with attachments:
175+
176+ add_attachment
177+ ^^^^^^^^^^^^^^
178+
138179.. code :: python
139180
140181 message = sendgrid.Mail()
141182 message.add_attachment(' stuff.txt' , ' ./stuff.txt' )
142183 # or
143184 message.add_attachment(' stuff.txt' , open (' ./stuff.txt' , ' rb' ))
144- # or
185+
186+ add_attachment_stream
187+ ^^^^^^^^^^^^^^^^^^^^^
188+
189+ .. code :: python
190+
191+ message = sendgrid.Mail()
145192 message.add_attachment_stream(' filename' , ' somerandomcontentyouwant' )
146193 # strings, unicode, or BytesIO streams
147-
148- Set Content ID's
149- ~~~~~~~~~~~~~~~~~~~~
194+
195+ add_content_id
196+ ^^^^^^^^^^^^^^
150197
151198.. code :: python
152199
@@ -178,8 +225,22 @@ There are implementations for setter methods too.
178225
179226 message = sendgrid.Mail()
180227 message.smtpapi.add_substitution(' key' , ' value' )
181- # or
228+
229+ add_substitution
230+ ^^^^^^^^^^^^^^^^
231+
232+ .. code :: python
233+
234+ message = sendgrid.Mail()
182235 message.add_substitution(' key' , ' value' )
236+
237+ set_substitutions
238+ ^^^^^^^^^^^^^^^^
239+
240+ .. code :: python
241+
242+ message = sendgrid.Mail()
243+ message.set_substitutions({' key1' : [' value1' , ' value2' ], ' key2' : [' value3' , ' value4' ]})
183244
184245 `Section `_
185246~~~~~~~~~~
@@ -188,8 +249,22 @@ There are implementations for setter methods too.
188249
189250 message = sendgrid.Mail()
190251 message.smtpapi.add_section(' section' , ' value' )
191- # or
252+
253+ add_section
254+ ^^^^^^^^^^^
255+
256+ .. code :: python
257+
258+ message = sendgrid.Mail()
192259 message.add_section(' section' , ' value' )
260+
261+ set_sections
262+ ^^^^^^^^^^^^
263+
264+ .. code :: python
265+
266+ message = sendgrid.Mail()
267+ message.set_sections({' section1' : ' value1' , ' section2' : ' value2' })
193268
194269 `Category `_
195270~~~~~~~~~~~
@@ -198,8 +273,22 @@ There are implementations for setter methods too.
198273
199274 message = sendgrid.Mail()
200275 message.smtpapi.add_category(' category' )
201- # or
276+
277+ add_category
278+ ^^^^^^^^^^^^
279+
280+ .. code :: python
281+
282+ message = sendgrid.Mail()
202283 message.add_category(' category' )
284+
285+ set_categories
286+ ^^^^^^^^^^^^^^
287+
288+ .. code :: python
289+
290+ message = sendgrid.Mail()
291+ message.set_categories([' category1' , ' category2' ])
203292
204293 `Unique Arguments `_
205294~~~~~~~~~~~~~~~~~~~
@@ -208,8 +297,22 @@ There are implementations for setter methods too.
208297
209298 message = sendgrid.Mail()
210299 message.smtpapi.add_unique_arg(' key' , ' value' )
211- # or
300+
301+ add_unique_arg
302+ ^^^^^^^^^^^^^^
303+
304+ .. code :: python
305+
306+ message = sendgrid.Mail()
212307 message.add_unique_arg(' key' , ' value' )
308+
309+ set_unique_args
310+ ^^^^^^^^^^^^^^^
311+
312+ .. code :: python
313+
314+ message = sendgrid.Mail()
315+ message.set_unique_args({' key1' : ' value1' , ' key2' : ' value2' })
213316
214317 `Filter `_
215318~~~~~~~~~
@@ -218,9 +321,22 @@ There are implementations for setter methods too.
218321
219322 message = sendgrid.Mail()
220323 message.smtpapi.add_filter(' filter' , ' setting' , ' value' )
221- # or
324+
325+ add_filter
326+ ^^^^^^^^^^
327+
328+ .. code :: python
329+
330+ message = sendgrid.Mail()
222331 message.add_filter(' filter' , ' setting' , ' value' )
332+
333+ Using Templates from the Template Engine
334+ ~~~~~~~~~~~~~~~~~
223335
336+ .. code :: python
337+
338+ message.add_filter(' templates' , ' enable' , ' 1' )
339+ message.add_filter(' templates' , ' template_id' , ' TEMPLATE-ALPHA-NUMERIC-ID' )
224340
225341 Tests
226342~~~~~
0 commit comments