Solved

Sending an attachement from C

Posted on 2002-04-18
7
261 Views
Last Modified: 2010-04-16
I need to send an html email with the text file attached from inside C code. The program runs on Linux and uses sendmail. The code that I use is the following:

fprintf(MAIL,"To: %s\n",buy_data.u_email);
fprintf(MAIL,"From: orders@babylon.com\n");
fprintf(MAIL,"Sender: XXXXXXXXXXXXX\n");
fprintf(MAIL,"Subject: XXXXXXXXXXXXXXXXXX\n");
fprintf(MAIL,"Reply-To: XXXXXXXXXXXXXX\n");
fprintf(MAIL,"Return-Path: XXXXXXXXXXXXX\n");
fprintf(MAIL,"Precedence: first-class\n");
fprintf(MAIL,"Mime-Version: 1.0\n");
fprintf(MAIL,"Content-Type: multipart/mixed; boundary=\"theBoundaryString\"\n");
fprintf(MAIL,"\n");
fprintf(MAIL,"--theBoundaryString\n\n");
         
     // print the text email
     fprintf(MAIL,"\n");
         
     fprintf(MAIL,"--theBoundaryString\n");
     fprintf(MAIL,"Content-Type: text/html");

if (strstr(buy_data.lang,"jpn")!=NULL) fprintf(MAIL," ;charset=UTF-8"); // japanese encoding
else fprintf(MAIL," ;charset=iso-8859-1"); // european encoding
fprintf(MAIL,"\n\n");
         
     // print the html email
fprintf(MAIL,"\n");
fprintf(MAIL,"--theBoundaryString--\n\n");
                   
fclose(MAIL);

The above code works for european languages but when I try to send the email in japanese there is no attachement (in Netscape I can see it but no in Outlook). Any ideas why? Am I sending the attachement in a wrong way completely?
0
Comment
Question by:efim
7 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6951415
So you can see the attachment inside the email in Netscape and not in Outlook? This can only mean that the Outlook version you are using does not support japanese attachments.

Have you tried upgrading the program?

CJ
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6951435
Also, it might be the exchange server (if that is the one you use).

CJ
0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6971836
why don't you try out using 'system' call and calling
'uuencode'?

or

you may write all commands in a shell program and call it through 'C' program.

It works for me on DYNIX/PTX. I guess should work on Linux.
See

man uuencode

for more help.

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Expert Comment

by:quirkyquirky
ID: 7299410
0
 

Expert Comment

by:ComTech
ID: 7300662
This person has been suspended for multiple violations of the Member Agreement, and will reject the proposed answer, and return your question to the Active Questions List.  The Moderator Group is deleting all 388 locked questions.

These were posted by three persons:

quirkyquirky
EliteKiller
liloXwin
 
Thank you,
ComTech
CS Admin @ EE
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7515036

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
Jgould earned 0 total points
ID: 7548103
Question has been closed as per recommendation

JGould-EE Moderator
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question