#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/timeb.h>
#include <string.h>
#ifdef __linux__
#include <unistd.h>
#else
#include <Windows.h>
#endif
{
}
int CreateDataFile(char *pathname)
{
FILE *file_ptr = NULL;
char fill_data[250];
if ((file_ptr = fopen(pathname, "w")) == NULL)
{
printf("Error Failed to open example data file.\n");
}
strcpy(fill_data, "My test file for my email file attachment example.");
fwrite(fill_data, 1, strlen(fill_data), file_ptr);
fflush(file_ptr);
fclose(file_ptr);
}
int main(int argc, char *argv[])
{
char smtp_server_address[50];
char email_account_username[50];
char email_account_password[50];
char email_address[50];
char email_name[50];
char ca_path_and_filename[100];
char to_email_address[50];
char to_email_name[50];
char email_subject[50];
char email_message[50];
char filename[256];
char pathname[256];
struct timeb timebuffer;
char home_path[256];
{
}
ftime(&timebuffer);
sprintf(filename, "email_file_example_%u.txt", (unsigned int)timebuffer.time);
sprintf(pathname, "%s/%s", home_path,filename);
if (CreateDataFile(pathname) ==
FAIL)
{
}
strcpy(smtp_server_address, "smtp.gmail.com");
strcpy(email_account_username, "mrsock@gmail.com");
strcpy(email_account_password, "liveandprosper");
strcpy(email_address, "mrsock@gmail.com");
strcpy(email_name, "Mr Sock");
strcpy(ca_path_and_filename,"curl-ca-bundle.crt");
email_address, email_name, verify_cert_authorities, generate_curl_debug_messages) ==
SUCCESS)
{
{
strcpy(to_email_address, "captkirt@nasa.gov");
strcpy(to_email_name, "Captain Kirt");
{
strcpy(email_subject, "Dogs and Cats");
strcpy(email_message, "Dogs are smarter than cats.");
{
printf("Error Failed to SendEmailWithFile.\n");
return 0;
}
}
else
{
printf("Error Failed to AddToEmailAddress.\n");
return 0;
}
}
else
{
printf("Error Failed to SetCertAuthoritesPathAndFilename.\n");
return 0;
}
}
else
{
printf("Error Failed to InitializeToolkitEmail.\n");
return 0;
}
#ifdef __linux__
sleep(10);
#else
Sleep(10000);
#endif
char config_pathname[256];
sprintf(config_pathname, "%s/email_config.txt", home_path);
ftime(&timebuffer);
sprintf(filename, "email_file_example_%u.txt", (unsigned int)timebuffer.time);
sprintf(pathname, "%s/%s", home_path, filename);
if (CreateDataFile(pathname) ==
FAIL)
{
}
{
printf("Error Failed to InitToolkitEmail.\n");
}
else
{
strcpy(email_subject, "Dogs and Cats");
strcpy(email_message, "Dogs are smarter than cats.");
{
printf("Error Failed to SendEmailWithFile.\n");
return 0;
}
}
#ifdef __linux__
sleep(10);
#else
Sleep(10000);
#endif
return 0;
}
Message codes and structure definition for the Device Service library.
boolean_type
Boolean enumeration.
Definition: ds_shared.h:104
@ TRUE_OR_YES
True.
Definition: ds_shared.h:106
Structure of parameters needed for message support.
Definition: trek_toolkit_common_api_ansi_c.h:74
char message[MAX_MESSAGE_SIZE]
Message.
Definition: trek_toolkit_common_api_ansi_c.h:77
enum message_category category
Message category (e.g., MSG_CAT_ERROR, MSG_CAT_ERROR_ALERT, MSG_CAT_WARNING, MSG_CAT_WARNING_ALERT,...
Definition: trek_toolkit_common_api_ansi_c.h:76
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8
#define FAIL
The function failed for an unknown reason.
Definition: trek_error.h:9