I am trying to automate mutt in C. To send a mail with attachment in mutt one can use: echo "what_you_want_to_print_in_body" | mutt -s "Subject" -a "file_path" -- [email protected] but when I automate the same using this C program:
#include<stdio.h>
int main()
{
char echo_message[1000];
char path[1000];
char subject[1000];
char recepient[1000];
printf("Enter your mail message: ");
gets(echo_message);
printf("Enter the path: ");
gets(path);
printf("Enter the subject: ");
gets(subject);
printf("Enter the recipient address: ");
gets(recepient);
system("echo \"%s\" | mutt -s \"%s\" -a \"%s\" -- \"%s\"", &echo_message, &subject, &path, &recepient);
return 0;
}
I get an error saying:
Can't stat %s: No such file or directory
%s: unable to attach a file.
I asked this question here as my concern was whether my system() script is valid, if not how should I proceed to automate this task.
system()library function only takes a single argument, a string.