4 * @defgroup EMAILSVC Email Service
6 <h1 class="pg">Introduction</h1>
7 <h2 class="pg">Overview </h2>
8 Electronic mail, most commonly abbreviated email or e-mail, is a method of exchanging digital messages. E-mail systems are based on a store-and-forward model in which e-mail server computer systems accept, forward, deliver and store messages on behalf of users, who only need to connect to the e-mail infrastructure, typically an e-mail server, with a network-enabled device for the duration of message submission or retrieval.
10 <h2 class="pg">Purpose of Programming Guide</h2>
11 This document is mainly aimed at the core functionality of the Email Service. The EMail Service component is implemented by Samsung to provide EMail service to applications that make use of EMail Engine. Email Engine provides functionality for the user like composing mail, saving mail, sending mail, and creating user mailbox according to the settings. Mobile subscribers can use the Email Engine to perform storage opearations such as save, update, get, delete and transport operations such as send, download and other email operations.
13 This programming guide is prepared for application developers who will use the email-service. It contains:
14 - List of features offered by email-service
15 - Information on How to use APIs provided by the email-service
18 <h2 class="pg">Target Domain / Application</h2>
19 The Email Service Layer can be utilized by any component in the application layer which allow the end user to perform the email related operations such as save, send, download email message and others.
21 For Example, the Email Service APIs shall be invoked by
22 @li Multimedia application when user opts to send media file through email
23 @li Email application when user tries to send an email message
25 <h2 class="pg">Terminology & Acronyms</h2>
27 <tr><th>Terminology</th><th>Description</th></tr>
28 <tr><td>Email </td><td>Electronic mail</td></tr>
29 <tr><td>IMAP</td><td>Internet Message Access Protocol</td></tr>
30 <tr><td>SMTP</td><td>Simple mail transfer protocol for sending mails</td></tr>
31 <tr><td>POP3</td><td>Post office protocol for receiving mails</td></tr>
32 <tr><td>RFC822</td><td>Describes mail header, to address, cc, bcc etc. formats and decoding and encoding standards. </td></tr>
33 <tr><td>OMA </td><td>Open Moblie Alliance</td></tr>
39 @defgroup Email_Architecture 1. Email Service Architecture
42 <h1 class="pg">Email-service Architecture</h1>
43 <h2 class="pg">System Architecture</h2>
44 @image html email_image001.png
46 <h2 class="pg">Process Architecture</h2>
47 @image html email_image002.png email-service Process view
49 @image html email_image003.png email-service Process architecture
51 Whenever an application wants to use email-service, it will call APIs from Email MAPI layer. Email MAPI layer APIs will internally call APIs provided by email framework module.
54 @defgroup Email_Feature 2. Email Service Feature
57 <h1 class="pg">Email-service Features</h1>
59 <tr><th>Feature </th><th>API Reference</th></tr>
60 <tr><td>Account Operation</td>
62 @n email_add_account()
63 @n email_delete_account()
64 @n email_update_account()
65 @n email_get_account()
66 @n email_get_account_list()
67 @n email_free_account()
68 @n email_validate_account()
71 <tr><td>mailbox Operation </td>
73 @n email_add_mailbox()
74 @n email_delete_mailbox()
75 @n email_update_mailbox()
76 @n email_get_mailbox_list()
77 @n email_get_mailbox_by_name()
78 @n email_get_child_mailbox_list()
79 @n email_get_mailbox_by_mailbox_type()
82 <tr><td>Message Operation </td>
84 @n email_add_message()
85 @n email_update_message()
87 @n email_delete_mail()
88 @n email_delete_all_mails_in_mailbox()
89 @n email_clear_mail_data()
90 @n email_add_attachment()
91 @n email_delete_attachment()
93 @n email_free_mail_info()
94 @n email_get_header_info()
95 @n email_free_header_info()
96 @n email_get_body_info()
97 @n email_free_body_info()
98 @n email_get_attachment_data()
99 @n email_free_attachment_info()
101 @n email_modify_mail_flag()
102 @n email_modify_seen_flag()
103 @n email_modify_extra_mail_flag()
104 @n email_move_mail_to_mailbox()
105 @n email_move_all_mails_to_mailbox()
106 @n email_count_message_with_draft_flag()
107 @n email_count_message_on_sending()
108 @n email_get_mailbox_list()
109 @n email_free_mailbox()
111 @n email_get_mail_flag()
112 @n email_free_mail_list()
113 @n email_release_mail()
114 @n email_retry_sending_mail()
115 @n email_make_db_full()
116 @n email_get_mailbox_name_by_mail_id()
117 @n email_cancel_sending_mail()
118 @n email_count_message_all_mailboxes()
119 @n email_get_latest_unread_mail_id()
120 @n email_get_max_mail_count()
121 @n email_get_disk_space_usage()
124 <tr><td>Network Operation </td>
127 @n email_sync_header()
128 @n email_download_body()
129 @n email_download_attachment()
130 @n email_cancel_job()
131 @n email_get_pending_job()
132 @n email_get_network_status()
133 @n email_send_report()
134 @n email_send_saved()
135 @n email_sync_imap_mailbox_list()
136 @n email_sync_local_activity()
139 <tr><td>Rule Operation </td>
142 @n email_get_rule_list()
144 @n email_update_rule()
145 @n email_delete_rule()
149 <tr><td>Control Operation </td>
151 @n email_init_storage()
154 @n email_service_begin()
155 @n email_service_end()
162 @defgroup Use_Case1_account Account Operation
163 @ingroup EMAIL_USECASES
165 <h2 class="pg">Account Operation </h2>
166 Account Operations are a set of operations to manage email accounts like add, update, delete or get account related details.
169 email_account_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
172 <td>Return Value / Exceptions</td></tr>
174 <tr><td>int email_add_account(email_account_t* account)</td>
175 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* account should be allocated and deallocated by Application</td></tr>
177 <tr><td>int email_delete_account(int account_id) </td>
178 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
180 <tr><td>int email_update_account(int account_id , email_account_t* new_account) </td>
181 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* new_account should be allocated and deallocated by Application</td></tr>
183 <tr><td>int email_get_account(int account_id, int pulloption, email_account_t** account) </td>
184 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param account will happen in email_get_account (). To free this memory, application should call email_free_account ()</td></tr>
186 <tr><td>int email_get_account_list(email_account_t** account_list, int* count) </td>
187 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: Memory allocation for param ccount_list will happen in email_get_account_list (). To free this memory, application should call email_free_account () </td></tr>
189 <tr><td>int email_free_account(email_account_t** account_list, int count) </td>
190 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
192 <tr><td>int email_validate_account(int account_id, int *handle)</td>
193 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
201 /* Assign values for new account */
202 email_account_t *account = NULL;
204 account = malloc(sizeof(email_account_t));
205 memset(account, 0x00, sizeof(email_account_t));
207 account->retrieval_mode = 1;
208 account->incoming_server_secure_connection = 1;
209 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
210 account->outgoing_server_port_number = EMAIL_SMTP_PORT;
211 account->outgoing_server_need_authentication = 1;
212 account->account_name = strdup("gmail");
213 account->display_name = strdup("Tom");
214 account->user_email_address = strdup("tom@gmail.com");
215 account->reply_to_addr = strdup("tom@gmail.com");
216 account->return_addr = strdup("tom@gmail.com");
217 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
218 account->incoming_server_address = strdup("pop3.gmail.com");
219 account->incoming_server_port_number = 995;
220 account->incoming_server_secure_connection = 1;
221 account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL;
222 account->incoming_server_user_name = strdup("tom");
223 account->password = strdup("tioimi");
224 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
225 account->outgoing_server_address = strdup("smtp.gmail.com");
226 account->outgoing_server_port_number = 587;
227 account->outgoing_server_secure_connection = 0x02;
228 account->outgoing_server_need_authentication = 1;
229 account->outgoing_server_user_name = strdup("tom@gmail.com");
230 account->sending_password = strdup("tioimi");
231 account->auto_resend_times = 3;
232 account->incoming_server_requires_apop = 0;
235 account->is_preset_account = 1;
236 account->logo_icon_path = strdup("Logo Icon Path");
237 account->options.priority = 3;
238 account->options.keep_local_copy = 0;
239 account->options.req_delivery_receipt = 0;
240 account->options.req_read_receipt = 0;
241 account->options.download_limit = 0;
242 account->options.block_address = 0;
243 account->options.block_subject = 0;
244 account->options.display_name_from = strdup("Display name from");
245 account->options.reply_with_body = 0;
246 account->options.forward_with_files = 0;
247 account->options.add_myname_card = 0;
248 account->options.add_signature = 0;
249 account->options.signature = strdup("Signature");
250 account->check_interval = 0;
252 if(EMAIL_ERROR_NONE != email_add_account(account))
258 *account_id = account->account_id; /* Use this returned account id when calling APIs which need it */
262 email_free_account(&account, 1);
270 email_account_t *account = NULL;
271 int account_id = 1; /* account id to be gotten */
273 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account))
279 email_free_account(&account, 1);
287 email_account_t *new_account = NULL;
288 int account_id = 1; /* account id to be updated */
290 /* Get account to be updated */
291 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&new_account))
296 /* Set the new values */
297 new_account->flag1 = 1;
298 new_account->account_name = strdup("gmail");
299 new_account->display_name = strdup("Tom001");
300 new_account->options.keep_local_copy = 1;
301 new_account->check_interval = 55;
303 if(EMAIL_ERROR_NONE != email_update_account(account_id,new_account))
309 email_free_account(&new_account, 1);
317 int account_id = 1; /* account id to be deleted */
319 if(EMAIL_ERROR_NONE != email_delete_account(account_id))
327 @li Get list of accounts
329 /* Get list of accounts */
331 email_account_t *account_list = NULL;
335 if(EMAIL_ERROR_NONE != email_get_account_list(&account_list,&count))
340 for ( i = 0; i < count; i++ )
342 /* Do something with each account */
343 printf("account id : %d\n", account_list[i].account_id);
348 email_free_account(&account_list,count);
352 @li Validate account - try to connect to server
354 /* Validate account - try to connect to server */
355 unsigned account_handle = 0;
358 if(EMAIL_ERROR_NONE != email_validate_account(account_id,&account_handle))
365 @image html email_image004.png
368 @defgroup Use_Case2_folder mailbox Operation
369 @ingroup EMAIL_USECASES
371 <h2 class="pg">mailbox Operation </h2>
372 mailbox Operations are a set of operations to manage email mailboxes like add, update, delete or get mailbox related details.
375 email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
378 <tr><td>API</td><td>Return Value / Exceptions</td></tr>
380 <tr><td>int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle) </td>
381 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* new_mailbox should be allocated and deallocated by Application </td></tr>
383 <tr><td>int email_delete_mailbox(email_mailbox_t* mailbox, int on_server, int *handle) </td>
384 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
386 <tr><td>int email_update_mailbox(email_mailbox_t*old_mailbox, email_mailbox_t* new_mailbox)</td>
387 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* old_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
389 <tr><td>int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t** mailbox_list, int* count)</td>
390 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
392 <tr><td>int email_get_mailbox_by_name(int account_id, const char *pMailboxName, email_mailbox_t **pMailbox)</td>
393 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param pMailbox will happen in email_get_mailbox_by_name (). To free this memory application should call email_free_mailbox</td></tr>
395 <tr><td>int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, email_mailbox_t** mailbox_list, int* count)</td>
396 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_child_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
398 <tr><td>int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)</td>
399 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_by_mailbox_type (). To free this memory application should call email_free_mailbox</td></tr>
404 @li Create new mailbox
406 email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
410 mailbox = malloc(sizeof(email_mailbox_t));
411 memset(mailbox, 0x00, sizeof(email_mailbox_t));
413 mailbox->mailbox_name = strdup("Personal");
414 mailbox->alias = strdup("selfuse");
415 mailbox->account_id = 1;
416 mailbox->local = on_server;
417 mailbox->mailbox_type = 7;
419 /* create new mailbox */
420 if(EMAIL_ERROR_NONE != email_add_mailbox(mailbox,on_server,&handle))
428 @li Update and Delete mailbox
430 email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
434 new_mailbox = malloc(sizeof(email_mailbox_t));
435 memset(new_mailbox, 0x00, sizeof(email_mailbox_t));
437 new_mailbox->mailbox_name = strdup("Personal001");
440 if(EMAIL_ERROR_NONE != email_update_mailbox(mailbox,new_mailbox))
446 if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,on_server,&handle))
451 email_free_mailbox(&mailbox, 1);
452 email_free_mailbox(&new_mailbox, 1);
456 @li Get list of mailboxes
460 email_mailbox_t* mailbox_list = NULL;
463 /*get list of mailboxes */
464 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, local_yn, &mailbox_list, &count))
469 email_free_mailbox(&mailbox_list,count);
474 @image html email_image005.png
477 @defgroup Use_Case3_message Message Operation
478 @ingroup EMAIL_USECASES
480 <h2 class="pg">Message Operation </h2>
481 Message Operations are a set of operations to manage email messages like add, update, delete or get message related details.
487 <td>Return Value / Exceptions</td></tr>
489 <tr><td>int email_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas) </td>
490 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
492 <tr><td>int email_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas) </td>
493 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
495 <tr><td>int email_count_mail(email_mailbox_t* mailbox, int* total, int* unseen) </td>
496 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
498 <tr><td>int email_delete_mail(email_mailbox_t* mailbox, int *mail_ids, int num, int from_server) </td>
499 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
501 <tr><td>int email_delete_all_mails_in_mailbox(email_mailbox_t* mailbox, int from_server) </td>
502 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
504 <tr><td>int email_clear_mail_data() </td>
505 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
507 <tr><td>int email_add_attachment(email_mailbox_t* mailbox, int mail_id, email_attachment_data_t* attachment)</td>
508 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox and mf_attachment_info_t* attachment hould be allocated and deallocated by Application</td></tr>
510 <tr><td>int email_delete_attachment(email_mailbox_t * mailbox, int mail_id, const char * attachment_id)</td>
511 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
513 <tr><td>int email_get_attachment_data(email_mailbox_t* mailbox, int mail_id, const char* attachment_id, email_attachment_data_t** attachment)</td>
514 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.@n Remarks:
515 -# Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
516 -# Memory allocation for param email_attachment_data_t** attachment will happen in email_get_attachment_data (). To free this memory, application should call email_free_attachment_info () </td></tr>
518 <tr><td>int email_free_attachment_info(email_attachment_data_t** atch_info) </td>
519 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
521 <tr><td>int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) </td>
522 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application</td></tr>
524 <tr><td>int email_move_mail_to_mailbox(int *mail_ids, int num, email_mailbox_t* new_mailbox) </td>
525 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
527 <tr><td>int email_move_all_mails_to_mailbox(email_mailbox_t* src_mailbox, email_mailbox_t* new_mailbox) </td>
528 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* src_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
530 <tr><td>int email_count_message_with_draft_flag(email_mailbox_t* mailbox, int* total) </td>
531 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
533 <tr><td>int email_count_message_on_sending(email_mailbox_t* mailbox, int* total) </td>
534 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
536 <tr><td>int email_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count ) </td>
537 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param email_mailbox_t** mailbox_list will happen in email_get_mailbox_list (). To free this memory, application should call email_free_mailbox ()</td></tr>
539 <tr><td>int email_free_mailbox(email_mailbox_t** mailbox_list, int count) </td>
540 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
542 <tr><td>int email_retry_sending_mail( int mail_id, int timeout_in_sec) </td>
543 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
545 <tr><td>int email_make_db_full()</td>
546 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
548 <tr><td>int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)</td>
549 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
551 <tr><td>int email_cancel_sending_mail( int mail_id) </td>
552 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
554 <tr><td>int email_count_message_all_mailboxes(email_mailbox_t* mailbox, int* total, int* unseen) </td>
555 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
557 <tr><td>int email_get_latest_unread_mail_id(int account_id, int *pMailID) </td>
558 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
560 <tr><td>int email_get_max_mail_count(int *Count) </td>
561 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
563 <tr><td>int email_get_disk_space_usage(unsigned long *total_size)</td>
564 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
569 @li Add, Update, Count and Delete message
571 email_mailbox_t *mailbox = NULL;
572 int on_server = 0, account_id = 0, mail_id = 0;
573 char *pFilePath = "/tmp/mail.txt";
577 int attachment_count = 0;
578 int err = EMAIL_ERROR_NONE;
579 char arg[50] = { 0 , };
580 char *body_file_path = MAIL_HOME"/tmp/mail.txt";
581 email_mailbox_t *mailbox_data = NULL;
582 email_mail_data_t *test_mail_data = NULL;
583 email_attachment_data_t *attachment_data = NULL;
584 email_meeting_request_t *meeting_req = NULL;
587 printf("\n > Enter account id : ");
588 scanf("%d", &account_id);
590 memset(arg, 0x00, 50);
591 printf("\n > Enter mailbox name : ");
594 email_get_mailbox_by_name(account_id, arg, &mailbox_data);
596 test_mail_data = malloc(sizeof(email_mail_data_t));
597 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
599 printf("\n From EAS? [0/1]> ");
600 scanf("%d", &from_eas);
602 test_mail_data->account_id = account_id;
603 test_mail_data->save_status = 1;
604 test_mail_data->flags_seen_field = 1;
605 test_mail_data->file_path_plain = strdup(body_file_path);
606 test_mail_data->mailbox_name = strdup(mailbox_data->mailbox_name);
607 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
608 test_mail_data->full_address_from = strdup("<test1@test.com>");
609 test_mail_data->full_address_to = strdup("<test2@test.com>");
610 test_mail_data->full_address_cc = strdup("<test3@test.com>");
611 test_mail_data->full_address_bcc = strdup("<test4@test.com>");
612 test_mail_data->subject = strdup("Meeting request mail");
614 body_file = fopen(body_file_path, "w");
616 for(i = 0; i < 500; i++)
617 fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2");
622 if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE)
623 printf("email_add_mail failed. [%d]\n", err);
625 printf("email_add_mail success.\n");
628 /* variable 'mail' should be filled with data on DB. */
629 /* And change values you want to update. */
630 mail->head->subject = strdup("save.mailbox again...");
632 if(EMAIL_ERROR_NONE != email_update_message(mail_id,mail))
638 int total = 0, unseen = 0;
640 /* Get the total number of mails and the number of unseen mails */
641 if(EMAIL_ERROR_NONE != email_count_mail(mailbox,&total,&unseen))
647 int *mail_ids, num = 0;
649 if(EMAIL_ERROR_NONE != email_delete_mail(mailbox,mail_ids,num,on_server))
655 @li Delete all message in a specific mailbox
657 /* Delete all message in mailbox */
658 email_mailbox_t *mailbox = NULL;
661 mailbox = malloc(sizeof(email_mailbox_t));
662 memset(mailbox, 0x00, sizeof(email_mailbox_t));
664 mailbox->account_id = 1;
665 mailbox->mailbox_name = strdup("INBOX");
667 if( EMAIL_ERROR_NONE != email_delete_all_mails_in_mailbox(mailbox, on_server))
675 @li Clear all messages
677 /* clear mail data */
678 if(EMAIL_ERROR_NONE != email_clear_mail_data())
687 int mail_id[],account_id = 1;
688 email_mailbox_t *mailbox = NULL;
689 char *mailbox_name = "INBOX";
691 mailbox = malloc(sizeof(email_mailbox_t));
692 memset(mailbox, 0x00, sizeof(email_mailbox_t));
694 mailbox->account_id = account_id;
695 mailbox->mailbox_name = mailbox_name;
697 /* Move mail to given mailbox*/
698 if(EMAIL_ERROR_NONE != email_move_mail_to_mailbox(/*mail_id*/,/*num*/,mailbox))
704 email_free_mailbox(&mailbox,1);
706 email_mailbox_t *src_mailbox = NULL,*dest_mailbox = NULL;
707 int src_account_id = 0, dest_account_id = 0;
708 char * src_mailbox_name = NULL, *dest_mailbox_name = NULL;
710 src_mailbox = malloc(sizeof(email_mailbox_t));
711 memset(src_mailbox, 0x00, sizeof(email_mailbox_t));
713 dest_mailbox = malloc(sizeof(email_mailbox_t));
714 memset(dest_mailbox, 0x00, sizeof(email_mailbox_t));
716 src_mailbox->account_id = /*src_account_id*/;
717 src_mailbox->mailbox_name = /*src_mailbox_name*/
719 dest_mailbox->account_id = /*dest_account_id*/;
720 dest_mailbox->mailbox_name = /*dest_mailbox_name*/
722 /*move all mails to given mailbox*/
723 if(EMAIL_ERROR_NONE != email_move_all_mails_to_mailbox(src_mailbox,dest_mailbox))
729 email_free_mailbox(&src_mailbox,1);
730 email_free_mailbox(&dest_mailbox,1);
732 int account_id = 0, total = 0;
733 email_mailbox_t *mailbox = NULL;
734 char *mailbox_name = NULL;
736 mailbox = malloc(sizeof(email_mailbox_t));
737 memset(mailbox, 0x00, sizeof(email_mailbox_t));
739 mailbox->account_id = /*account_id*/;
740 mailbox->mailbox_name = /*mailbox_name*/
742 /*count of draft msgs*/
743 if(EMAIL_ERROR_NONE != email_count_message_with_draft_flag(mailbox,&total))
749 email_free_mailbox(&mailbox,1);
752 @li Count of msgs sent from given folde
754 int account_id = 0, total = 0;
755 email_mailbox_t *mailbox = NULL;
756 char *mailbox_name = NULL;
758 mailbox = malloc(sizeof(email_mailbox_t));
759 memset(mailbox, 0x00, sizeof(email_mailbox_t));
761 mailbox->account_id = /*account_id*/;
762 mailbox->mailbox_name = /*mailbox_name*/
764 /*count of msgs sent from given mailbox*/
765 if(EMAIL_ERROR_NONE != email_count_message_on_sending(mailbox,&total))
771 email_free_mailbox(&mailbox,1);
779 email_mailbox_t* mailbox_list = NULL;
780 int account_id = 1, count = 0;
782 /* Get mailbox list*/
783 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,&mailbox_list,&count))
788 /* free mailbox list*/
789 email_free_mailbox(&mailbox,count);
793 @li Get mailBox name by mailID
795 /* Get mailBox name by mailID*/
797 char *pMailbox_name=strdup("INBOX");
798 err = email_get_mailbox_name_by_mail_id(mail_id,&pMailbox_name);
805 @li Cancel sending mail
808 /* email_cancel_sending_mail*/
809 int mail_id = 1; /* mail id of a mail which is on sending */
810 err = email_cancel_sending_mail(mail_id);
816 @li Get the Total count and Unread count of all mailboxes
818 /* Get the Total count and Unread count of all mailboxes */
819 email_mailbox_t* mailbox = NULL;
820 int account_id = 1, total = 0, unseen = 0;
821 char *mailbox_name = NULL;
823 mailbox = malloc(sizeof(email_mailbox_t));
824 memset(mailbox, 0x00, sizeof(email_mailbox_t));
826 mailbox->account_id = /*account_id*/;
827 mailbox->mailbox_name = /*mailbox_name*/
829 err = email_count_message_all_mailboxes(mailbox,&total,&unseen);
834 @image html email_image006.png
836 @image html email_image007.png
838 @image html email_image008.png
841 @defgroup Use_Case4_network Network Operation
842 @ingroup EMAIL_USECASES
844 <h2 class="pg">Network Operation </h2>
845 Network Operations are a set of operations to manage email send, receive and cancel related details.
848 email_option_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
851 <td>Return Value / Exceptions</td></tr>
853 <tr><td>int email_send_mail( email_mailbox_t* mailbox, int mail_id, int *handle)</td>
854 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
855 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
857 <tr><td>int email_sync_header(email_mailbox_t* mailbox, int *handle)</td>
858 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
859 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
861 <tr><td>int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, int *handle) </td>
862 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
863 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
865 <tr><td>int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth, int *handle)</td>
866 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
868 <tr><td>int email_cancel_job(int account_id, int handle)</td>
869 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
871 <tr><td>int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)</td>
872 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
874 <tr><td>void email_get_network_status(int* on_sending, int* on_receiving) </td>
875 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
877 <tr><td>int email_send_saved(int account_id, email_option_t* sending_option, int *handle)</td>
878 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
879 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
881 <tr><td>int email_sync_imap_mailbox_list(int account_id, const char* mailbox, int *handle)</td>
882 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
884 <tr><td>int email_sync_local_activity(int account_id)</td>
885 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
891 /* TODO : Write sample to send a mail. */
894 @li Download header of new emails from mail server
896 /* Download header of new emails from mail server*/
897 email_mailbox_t mailbox;
899 int err = EMAIL_ERROR_NONE;
902 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
904 mailbox.account_id = account_id;
905 mailbox.mailbox_name = strdup("INBOX");
906 err = email_sync_header (&mailbox,&handle);
910 @li Download email body from server
913 /*Download email body from server*/
914 email_mailbox_t mailbox;
918 int err = EMAIL_ERROR_NONE;
920 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
921 mailbox.account_id = account_id;
922 mailbox.mailbox_name = strdup("INBOX");
923 err= email_download_body (&mailbox,mail_id,0,&handle);
925 @li Download a email nth-attachment from server
927 /*Download a email nth-attachment from server*/
928 email_mailbox_t mailbox;
931 char arg[50]; /* Input attachment number need to be download */
933 int err = EMAIL_ERROR_NONE;
935 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
936 mailbox.mailbox_name = "INBOX";
937 mailbox.account_id = account_id;
938 err=email_download_attachment(&mailbox,mail_id,arg,&handle);
942 @image html email_image009.png
945 @defgroup Use_Case5_rule Rule Operation
946 @ingroup EMAIL_USECASES
948 <h2 class="pg">Rule Operation</h2>
949 Rule Operations are a set of operations to manage email rules like add, get, delete or update rule related details.
952 email_rule_t- refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
955 <td>Return Value / Exceptions</td></tr>
957 <tr><td>int email_get_rule(int filter_id, email_rule_t** filtering_set)</td>
958 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
959 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
960 -# De-allocation is to be done by application.</td></tr>
962 <tr><td>int email_get_rule_list(email_rule_t** filtering_set, int* count)</td>
963 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
964 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
965 -# De-allocation is to be done by application.</td></tr>
967 <tr><td>int email_add_rule(email_rule_t* filtering_set) </td>
968 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
969 -# Memory allocation and de-allocation is to be done by application.
970 -# Use email_free_rule to free allocated memory.</td></tr>
972 <tr><td>int email_update_rule(int filter_id, email_rule_t* new_set) </td>
973 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
974 -# Memory allocation and de-allocation is to be done by application.</td></tr>
975 -# Use email_free_rule to free allocated memory.
977 <tr><td>int email_delete_rule(int filter_id)</td>
978 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
980 <tr><td>int email_free_rule(email_rule_t** filtering_set, int count)</td>
981 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
987 int err = EMAIL_ERROR_NONE;
988 email_rule_t* rule = NULL;
991 /* Get a information of filtering*/
992 err = email_get_rule (filter_id,&rule);
993 err = email_free_rule (&rule,1);
995 /* Get all filterings */
997 err = email_get_rule_list(&rule,&count);
1000 /* Add a filter information */
1001 err = email_add_rule (rule);
1002 err = email_free_rule (&rule,1);
1004 /* Change a filter information */
1005 err = email_update_rule (filter_id,rule);
1006 err = email_free_rule (&rule,1);
1008 /* Delete a filter information*/
1009 err = email_delete_rule (filter_id);
1011 /* Free allocated memory */
1012 err = email_free_rule (&rule,1);
1016 @image html email_image010.png
1019 @defgroup Use_Case6_control Control Operation
1020 @ingroup EMAIL_USECASES
1022 <h2 class="pg">Control Operation</h2>
1023 Control Operations are a set of operations to manage Email MAPI Layer initialization.
1024 The Application which will use the MAPIs MUST initialize IPC proxy and conntect to Email FW database before calling other APIs.
1025 And it MUST finalize IPC proxy and disconnect to the DB if the application doesn't use APIs.
1029 <td>Return Value / Exceptions</td></tr>
1031 <tr><td>int email_init_storage(void)</td>
1032 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
1034 <tr><td>int email_open_db(void)</td>
1035 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1037 @n Application should call email_close_db once db operation is over</td></tr>
1039 <tr><td>int email_close_db(void)</td>
1040 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1042 @n This API should be called only if email_open_db () is called.</td></tr>
1044 <tr><td>int email_service_begin(void)</td>
1045 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
1047 <tr><td>int email_service_end(void)</td>
1048 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1050 @n This API should be called only if email_service_begin () is called.</td></tr>
1054 @li Initialize and Finalize Email MAPI Layer
1056 int err = EMAIL_ERROR_NONE;
1058 /* Initialize Email MAPI Layer before calling other MAPIs */
1059 if(EMAIL_ERROR_NONE == email_service_begin())
1061 if(EMAIL_ERROR_NONE != email_open_db())
1065 if(EMAIL_ERROR_NONE != email_init_storage())
1071 /* Call other MAPIs */
1075 /* Finalize Email MAPI Layer when finishing application */
1076 err = email_close_db();
1077 err = email_service_end();
1081 @image html email_image011.png
1084 @addtogroup Email_Feature
1086 <h1 class="pg">System Configuration</h1>
1087 <h2 class="pg">Files to be included</h2>
1091 <h2 class="pg">System Initialization and De-Initialization</h2>
1092 email_service_begin is used to initialize email-service at boot time.
1093 @n email_service_end is used to deinitialize email-service at shutdown.
1094 @n These two are separate executables.
1096 <h2 class="pg">Variable Configuration</h2>
1099 <h2 class="pg">Build Environment</h2>
1100 If the Application wants to use email-service Module, make sure that the following package should be included in the Makefile.
1104 <h2 class="pg">Runtime Environment</h2>
1108 @defgroup EMAL_Appendix 4. Reference
1111 <h1 class="pg">Appendix</h1>
1112 <h2 class="pg">Email</h2>
1113 @image html email_image012.png
1115 - Alice composed a message using MUA (Mail User Agent). Alice enters the e-mail address of her correspondent, and hits the "send" button.
1116 - MUA format the message using MIME and uses Simple mail Transfer Protocol to send the message to local MTA (Mail Transfer Agent) i,e smtp.a.org run by Alices ISP (Internet Service provider).
1117 - The MTA looks at the destination address provided in the SMTP protocol i,e bob@b.org. An Internet e-mail address is a string of the form localpart@exampledomain. The part before the @ sign is the local part of the address, often the username of the recipient, and the part after the @ sign is a domain name. The MTA resolves a domain name to determine the fully qualified domain name of the mail exchange server in the Domain Name System (DNS).
1118 - The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP.
1119 - smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob.
1120 - Bob presses the "get mail" button in his MUA, which picks up the message using the Post Office Protocol (POP3).
1122 <h2 class="pg">RFC</h2>
1123 -# RFC 2821-SMTP(Simple Mail Transfer Protocol)
1124 -# RFC 1939-POP3(Post Office Protocol)
1125 -# RFC 3501-IMAP4(Internate message protocol)
1131 * @defgroup EMAILSVC
1133 * @defgroup EMAIL_USECASES 3. API Description
1136 <h1 class="pg">API Description</h1>
1137 This section describes APIs and shows the example of using them.