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_FRAMEWORK
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.
44 * @remarks a email must be released with email_destroy_message() by you.
46 * @param[out] email A handle to the email message
48 * @return 0 on success, otherwise a negative error value.
49 * @retval #EMAIL_ERROR_NONE Successful
50 * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory
51 * @retval #EMAIL_ERROR_ACCOUNT_NOT_FOUND Email account not found
53 * @see email_destroy_message()
55 int email_create_message(email_h *email);
58 * @brief Destroys the email message handle and releases all its resources.
60 * @param[in] email The handle to the email message
62 * @return 0 on success, otherwise a negative error value.
63 * @retval #EMAIL_ERROR_NONE Successful
64 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
65 * @retval #EMAIL_ERROR_OPERATION_FAILED Operation failed
67 * @see email_create_message()
69 int email_destroy_message(email_h email);
72 * @brief Sets a subject of the email message.
74 * @param[in] email The handle to the email message
75 * @param[in] subject The subject of the email message
76 * @return 0 on success, otherwise a negative error value.
77 * @retval #EMAIL_ERROR_NONE Successful
78 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
79 * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory
81 * @see email_create_message()
83 int email_set_subject(email_h email, const char *subject);
86 * @brief Populates a body of the email message.
87 * @details Email message body means the text data to be delivered.
89 * @param[in] email The handle to the email message
90 * @param[in] body The message body
91 * @return 0 on success, otherwise a negative error value.
92 * @retval #EMAIL_ERROR_NONE Successful
93 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
94 * @retval # EMAIL_ERROR_OPERATION_FAILED Operation failed
95 * @pre An email message handle is created using #email_create_message().
96 * @see email_create_message()
98 int email_set_body(email_h email, const char *body);
101 * @brief Adds a recipient to the email message.
102 * @details The email API supports sending an email message to multiple recipients.
104 * @remarks Email address should be in standard format (as described in
105 * Internet standards RFC 5321 and RFC 5322).\n
107 * @param[in] email The handle to the email message
108 * @param[in] type The recipient type
109 * @param[in] address The recipient email address
111 * @return 0 on success, otherwise a negative error value.
112 * @retval #EMAIL_ERROR_NONE Successful
113 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
114 * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory
116 * @see email_create_message()
117 * @see email_remove_all_recipients()
119 int email_add_recipient(email_h email, email_recipient_type_e type, const char *address);
122 * @brief Removes all recipients for the email message.
124 * @param[in] email The handle to the email message
126 * @return 0 on success, otherwise a negative error value.
127 * @retval #EMAIL_ERROR_NONE Successful
128 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
130 * @see email_add_recipient()
132 int email_remove_all_recipients(email_h email);
135 * @brief Adds a file as an attachment to the email message.
136 * @details It should be used to add a file to the attachment list
137 * of the email message.
139 * @remarks The maximum attachment file size is 10MB.
141 * @param[in] email The handle to the email message
142 * @param[in] filepath The absolute full path of the file to be attached
144 * @return 0 on success, otherwise a negative error value.
145 * @retval #EMAIL_ERROR_NONE Successful
146 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
147 * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory
149 * @see email_remove_all_attachments()
152 int email_add_attach(email_h email, const char *filepath);
155 * @brief Clears all attachments of the email message.
157 * @param[in] email The handle to the email message
159 * @return 0 on success, otherwise a negative error value.
160 * @retval #EMAIL_ERROR_NONE Successful
161 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
163 * @see email_create_message()
164 * @see email_add_attach()
166 int email_remove_all_attachments(email_h email);
169 * @brief Save the email message at outbox.
171 * @remarks Get the id of mail.
174 * @param[in] email The handle to the email message
175 * @return 0 on success, otherwise a negative error value.
176 * @retval #EMAIL_ERROR_NONE Successful
177 * @retval #EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed.
178 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
180 * @see email_create_message()
181 * @see email_add_recipient()
182 * @see email_set_body()
183 * @see email_save_message
185 int email_save_message(email_h email);
189 * @brief Sends the email message.
191 * @remarks In order to check whether sending a message succeeds, \n you should register email_message_sent_cb() using #email_set_message_sent_cb().
194 * @param[in] email The handle to the email message
195 * @param[in] save_to_sentbox Set to true to save the message in the sentbox, else false
196 * @return 0 on success, otherwise a negative error value.
197 * @retval #EMAIL_ERROR_NONE Successful
198 * @retval #EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed.
199 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
201 * @see email_save_message()
202 * @see email_set_message_sent_cb()
204 int email_send_message(email_h email, bool save_to_sentbox);
208 * @brief Called when the process of sending an email finishes.
209 * @details You can check whether sending an email succeeds using this function.
212 * @param[in] email The handle to the email message
213 * @param[in] result The result of email message sending\n
214 * #EMAIL_SENDING_FAILED or #EMAIL_SENDING_SUCCEEDED
215 * @param[in] user_data The user data passed from the callback registration function
217 * @pre email_send_message() will invoke this callback if you register this callback using email_set_message_sent_cb().
219 * @see email_send_message()
220 * @see email_set_message_sent_cb()
221 * @see email_unset_message_sent_cb()
223 typedef void (* email_message_sent_cb)(email_h email, email_sending_e result, void *user_data);
226 * @brief Registers a callback function to be invoked when an email message is sent.
227 * @details You will be notified when sending a message finishes and check whether it succeeds using this function.
229 * @param[in] email The handle to the email message
230 * @param[in] callback The callback function to register
231 * @param[in] user_data The user data to be passed to the callback function
233 * @return 0 on success, otherwise a negative error value.
234 * @retval #EMAIL_ERROR_NONE Successful
235 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
236 * @post It will invoke email_message_sent_cb().
237 * @see email_message_sent_cb()
238 * @see email_unset_message_sent_cb()
239 * @see email_send_message()
241 int email_set_message_sent_cb(email_h email, email_message_sent_cb callback, void *user_data);
244 * @brief Unregisters the callback function.
246 * @param[in] email The handle to the email message
248 * @return 0 on success, otherwise a negative error value.
249 * @retval #EMAIL_ERROR_NONE Successful
250 * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter
252 * @see email_message_sent_cb()
253 * @see email_set_message_sent_cb()
254 * @see email_send_message()
256 int email_unset_message_sent_cb(email_h msg);
266 #endif /* __MESSAGING_EMAIL_H__ */