2 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __MESSAGING_EMAIL_H__
18 #define __MESSAGING_EMAIL_H__
21 * @addtogroup CAPI_MESSAGING_EMAIL_MODULE
27 * @ingroup CAPI_MESSAGING_EMAIL_MODULE
28 * @brief Messaging API file, support for sending email messages.
34 #include <email_types.h>
35 #include <email_error.h>
39 #endif /* __cplusplus */
42 * @brief Creates an email message handle for sending an email message.
45 * @privilege %http://tizen.org/privilege/email
47 * @remarks You must release @a email using email_destroy_message().
49 * @param[out] email A handle to the email message
51 * @return @c 0 on success,
52 * otherwise a negative error value
54 * @retval #EMAILS_ERROR_NONE Successful
55 * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory
56 * @retval #EMAILS_ERROR_ACCOUNT_NOT_FOUND Email account not found
58 * @pre At least one email account should be set up on the device.
60 * @see email_destroy_message()
62 int email_create_message(email_h *email);
65 * @brief Destroys the email message handle and releases all its resources.
68 * @param[in] email The handle to the email message
70 * @return @c 0 on success,
71 * otherwise a negative error value
73 * @retval #EMAILS_ERROR_NONE Successful
74 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
75 * @retval #EMAILS_ERROR_OPERATION_FAILED Operation failed
77 * @see email_create_message()
79 int email_destroy_message(email_h email);
82 * @brief Sets a subject of the email message.
85 * @param[in] email The handle to the email message
86 * @param[in] subject The subject of the email message
88 * @return @c 0 on success,
89 * otherwise a negative error value
91 * @retval #EMAILS_ERROR_NONE Successful
92 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
93 * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory
95 * @pre An email message handle is created using email_create_message().
97 * @see email_create_message()
99 int email_set_subject(email_h email, const char *subject);
102 * @brief Populates a body of the email message.
103 * @details Email message body means the text data to be delivered.
107 * @param[in] email The handle to the email message
108 * @param[in] body The message body
110 * @return @c 0 on success,
111 * otherwise a negative error value
113 * @retval #EMAILS_ERROR_NONE Successful
114 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
115 * @retval #EMAILS_ERROR_OPERATION_FAILED Operation failed
117 * @pre An email message handle is created using email_create_message().
119 * @see email_create_message()
121 int email_set_body(email_h email, const char *body);
124 * @brief Adds a recipient to the email message.
125 * @details The email API supports sending an email message to multiple recipients.
129 * @remarks Email address should be in standard format (as described in
130 * Internet standards RFC 5321 and RFC 5322).
132 * @param[in] email The handle to the email message
133 * @param[in] type The recipient type
134 * @param[in] address The recipient email address
136 * @return @c 0 on success,
137 * otherwise a negative error value
139 * @retval #EMAILS_ERROR_NONE Successful
140 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
141 * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory
143 * @pre An email message handle is created using email_create_message().
145 * @see email_create_message()
146 * @see email_remove_all_recipients()
148 int email_add_recipient(email_h email, email_recipient_type_e type, const char *address);
151 * @brief Removes all recipients for the email message.
154 * @param[in] email The handle to the email message
156 * @return @c 0 on success,
157 * otherwise a negative error value
159 * @retval #EMAILS_ERROR_NONE Successful
160 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
162 * @pre An email message handle is created using email_create_message().
164 * @see email_add_recipient()
166 int email_remove_all_recipients(email_h email);
169 * @brief Adds a file as an attachment to the email message.
170 * @details It should be used to add a file to the attachment list
171 * of the email message.
175 * @remarks The maximum attachment file size is 10MB.
177 * @param[in] email The handle to the email message
178 * @param[in] filepath The absolute full path of the file to be attached
180 * @return @c 0 on success,
181 * otherwise a negative error value
183 * @retval #EMAILS_ERROR_NONE Successful
184 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
185 * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory
187 * @pre An email message handle is created using email_create_message().
189 * @see email_remove_all_attachments()
192 int email_add_attach(email_h email, const char *filepath);
195 * @brief Clears all attachments of the email message.
198 * @param[in] email The handle to the email message
200 * @return @c 0 on success,
201 * otherwise a negative error value
203 * @retval #EMAILS_ERROR_NONE Successful
204 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
206 * @pre An email message handle is created using email_create_message().
208 * @see email_create_message()
209 * @see email_add_attach()
211 int email_remove_all_attachments(email_h email);
214 * @brief Saves the email message at outbox.
218 * @privilege %http://tizen.org/privilege/email
220 * @remarks Get the ID of mail.
222 * @param[in] email The handle to the email message
224 * @return @c 0 on success,
225 * otherwise a negative error value
227 * @retval #EMAILS_ERROR_NONE Successful
228 * @retval #EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed.
229 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
231 * @pre An email message handle is created using email_create_message().
233 * @see email_create_message()
234 * @see email_add_recipient()
235 * @see email_set_body()
236 * @see email_save_message
238 int email_save_message(email_h email);
242 * @brief Sends the email message.
246 * @privilege %http://tizen.org/privilege/email
248 * @remarks In order to check whether sending a message succeeds,
249 * you should register email_message_sent_cb() using email_set_message_sent_cb().
251 * @param[in] email The handle to the email message
252 * @param[in] save_to_sentbox Set to @c true to save the message in the sentbox,
253 * otherwise set to @c false to not save the message in the sentbox
255 * @return @c 0 on success,
256 * otherwise a negative error value
258 * @retval #EMAILS_ERROR_NONE Successful
259 * @retval #EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed
260 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
262 * @pre An email message is stored using email_save_message().
264 * @see email_save_message()
265 * @see email_set_message_sent_cb()
267 int email_send_message(email_h email, bool save_to_sentbox);
271 * @brief Called when the process of sending an email finishes.
272 * @details You can check whether sending an email succeeds using this function.
276 * @param[in] email The handle to the email message
277 * @param[in] result The result of email message sending \n
278 * #EMAIL_SENDING_FAILED or #EMAIL_SENDING_SUCCEEDED
279 * @param[in] user_data The user data passed from the callback registration function
281 * @pre email_send_message() will invoke this callback if you register this callback using email_set_message_sent_cb().
283 * @see email_send_message()
284 * @see email_set_message_sent_cb()
285 * @see email_unset_message_sent_cb()
287 typedef void (* email_message_sent_cb)(email_h email, email_sending_e result, void *user_data);
290 * @brief Registers a callback function to be invoked when an email message is sent.
291 * @details You will be notified when sending a message finishes and check whether it succeeds using this function.
295 * @param[in] email The handle to the email message
296 * @param[in] callback The callback function to register
297 * @param[in] user_data The user data to be passed to the callback function
299 * @return @c 0 on success,
300 * otherwise a negative error value
302 * @retval #EMAILS_ERROR_NONE Successful
303 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
305 * @post It will invoke email_message_sent_cb().
307 * @see email_message_sent_cb()
308 * @see email_unset_message_sent_cb()
309 * @see email_send_message()
311 int email_set_message_sent_cb(email_h email, email_message_sent_cb callback, void *user_data);
314 * @brief Unregisters the callback function.
317 * @param[in] msg The handle to the email message
319 * @return @c 0 on success,
320 * otherwise a negative error value
322 * @retval #EMAILS_ERROR_NONE Successful
323 * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter
325 * @see email_message_sent_cb()
326 * @see email_set_message_sent_cb()
327 * @see email_send_message()
329 int email_unset_message_sent_cb(email_h msg);
339 #endif /* __MESSAGING_EMAIL_H__ */