Solved

Sending an attachement from C

Posted on 2002-04-18
7
259 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
zeroMAx challenge 20 77
fix34  challenge 9 98
base64 decode encode 12 100
Scripting vs. Programming languages 25 117
A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

746 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

11 Experts available now in Live!

Get 1:1 Help Now