473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multipart alternative emails with attachment

Hello all,
Thanks in advance for your help
I have a problem in sending emails, my requirement is to send multipart alternative emails with attachments, I'm able to send text with attachments or HTML mails with attachments, but some mail clients are not able to display the html mails that is why I need to send multipart alternative emails, when I used multipart/alternative then I'm not able to send attachments and if I use the multipart/mixed then I'm able to send the attachments but in this case both the HTML content and the text content are displayed in the email.

below is the code I'm using

#!/usr/bin/perl -w

use CGI qw /:standard center/;
use CGI::Carp qw(fatalsToBrowser);
use HTTP::Request::Common;
use LWP::UserAgent;
use MIME::Lite;

my $msg = MIME::Lite->new(
From => '"abc" <abc@abc.com>',
To => 'xyz@xyz.com',
Subject => 'MultiPart Alternative 1',
Type => 'multipart/Mixed'
);

$msg->attach(
Type => 'text/html',
Data => '<body><h1>Test mail message this is HTML message</h1></body>'
);

$msg->attach(
Type => 'text/plain',
Data => 'Test mail message this is text message'
);


$part = MIME::Lite->new(
Type =>'image/jpeg',
Path => 'filename.jpg',
Filename => 'filename.jpg'
);


### Attach it to any message:
$msg->attach($part);

$msg->send("smtp", "127.0.0.1", Timeout => 30);
here when I execute this code I'm able to send the attachment but both the text content and email content dipslyed in the mail.
and in plce of
my $msg = MIME::Lite->new(
From => '"abc" <abc@abc.com>',
To => 'xyz@xyz.com',
Subject => 'MultiPart Alternative 1',
Type => 'multipart/Mixed'
);
if I used
my $msg = MIME::Lite->new(
From => '"abc" <abc@abc.com>',
To => 'xyz@xyz.com',
Subject => 'MultiPart Alternative 1',
Type => 'multipart/Alternative'
);
then I'm not able to send the attachment.
Please if any one has the solution about this then let me know ASAP , its very urgent.
Thanks with regards
Jan 17 '07 #1
0 2757

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: LRW | last post by:
Because I've had recipients of our newsletter tell us they can't (or won't) receive HTML e-mail, I found out how to make an e-mail that sends both HTML and a plaintext version in a multipart...
2
by: Damien | last post by:
Hi to all, After hours of attempts and "googling", I'm still pulling my hair off my head when I try to send multipart html emails. It "works" on PCs with Outlook when I juste send a single...
5
by: lucanos | last post by:
Hey All, I'm having trouble trying to create a PHP file which will generate a multipart email message (containing both an HTML formatted part and a Plain Text formatted part). I have Googled...
9
by: Phil W | last post by:
I'm using CDONTS and am trying to send an email out which displays in HTML for HTML-enabled clients, and plain text for non-HTML clients. Unfortunately I am using IIS4 so CDOSYS is not available...
0
by: justino | last post by:
I am trying to send out an email newsletter using both HTML and plain text? Any good resources for doing this? I can't seem to get it to display the TextBody when Outlook is set to display emails...
2
by: Der tolle Emil | last post by:
Hi! I wrote a little function to send emails which works quite well. I already managed to send attachments correctly (also more than 1 per email) but I am not able to send a HTML mail containing...
0
by: ptraj | last post by:
Dear ppls, I'm doing a small project to extract all messages from outlook by Visual Basic 6.0 and write them into a file(in MBOX format). While accessing messages i able to get headers, body,...
2
by: gezerpunta | last post by:
Hi I used pear api to make this mail but I can t add multipart.My mail structure is like that. part 1: a file part 2: multipart part 1: a file part 2: a file
0
by: =?Utf-8?B?Tmljb2w=?= | last post by:
Hi, I ahve developed an application to send mails with attachment to a common mail box say "help@company.com". All the mail that comes to this mailbox will be read by some application. All my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.