Solved

Sending an attachement from C

Posted on 2002-04-18
7
260 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now