Solved

Sending an attachement from C

Posted on 2002-04-18
7
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

733 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