Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > When use MIME::Lite module the attachment clip sign not shown for attachments

Reply
Thread Tools

When use MIME::Lite module the attachment clip sign not shown for attachments

 
 
Jane Humbrey
Guest
Posts: n/a
 
      08-27-2003
G'day. How can we show the attachment clip sign in receiver's inbox?.
Currently the receiver actually receive the attchment, but it won't show up
as a clip sign in Outlook/Outlook Express. Many people can't recognize the
attachment, because it won't show up as a paper clip sign.

use MIME::Lite::HTML;
use MIME::Lite;

my $mailHTML = new MIME::Lite::HTML
From => "dlcoordinator\@cs.org.au",
To => "$receiver",
Subject => "Solomon Islands leaflet attached";

my $MIMEmail = $mailHTML->parse("file://C|/test/coverpage/coverexec.htm");
$MIMEmail->attach(
Type => 'binary',
Path =>'SolomonIs.leaflet.doc' ,
Filename => 'SolomonIs.leaflet.doc' ,
Disposition => 'attachment'

);
$MIMEmail->send_by_smtp('sd.xdra.co.au');



Cheers

Jo


 
Reply With Quote
 
 
 
 
Jane Humbrey
Guest
Posts: n/a
 
      08-27-2003
Hi James

I changed the type as you said, but the paper clip didn't appear to show the
attachments in Outlook/Outlook Express : (.

Jo
"James Willmore" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Jane Humbrey" <(E-Mail Removed)> wrote in message

news:<ZjT2b.128239$(E-Mail Removed)>...
> > G'day. How can we show the attachment clip sign in receiver's inbox?.
> > Currently the receiver actually receive the attchment, but it won't show

up
> > as a clip sign in Outlook/Outlook Express. Many people can't recognize

the
> > attachment, because it won't show up as a paper clip sign.
> >
> > use MIME::Lite::HTML;
> > use MIME::Lite;
> >
> > my $mailHTML = new MIME::Lite::HTML
> > From => "dlcoordinator\@cs.org.au",
> > To => "$receiver",
> > Subject => "Solomon Islands leaflet attached";
> >
> > my $MIMEmail =

$mailHTML->parse("file://C|/test/coverpage/coverexec.htm");
> > $MIMEmail->attach(
> > Type => 'binary',
> > Path =>'SolomonIs.leaflet.doc' ,
> > Filename => 'SolomonIs.leaflet.doc' ,
> > Disposition => 'attachment'
> >
> > );
> > $MIMEmail->send_by_smtp('sd.xdra.co.au');

>
> Change your 'Type' to 'application/msword'. Because it's 'binary',
> it's going to look like, well, a binary file to the email client.
> Since the module is MIME::Lite, it's going to 'assign' a MIME type to
> your file - based upon RFC-2046 for MIME messages. If this were, say,
> a CSV file that you wanted users to open with Excel, the 'Type' would
> be 'application/vnd.ms-excel'.
>
> I did something like this using just MIME::Lite. I changed the MIME
> type to show the attachment as an Excel file - but it was really a CSV
> file with an xls extention. It worked great.
>
> HTH
>
> Jim



 
Reply With Quote
 
 
 
 
James Willmore
Guest
Posts: n/a
 
      08-28-2003
"Jane Humbrey" <(E-Mail Removed)> wrote in message news:<KY93b.129228$(E-Mail Removed)>...
> Hi James
>
> I changed the type as you said, but the paper clip didn't appear to show the
> attachments in Outlook/Outlook Express : (.
>
> Jo


Okay ... I wanted to do something similar ... and normally, I don't do
this, but .... here is some code for you to try.

First, change the directory to what you are using, and fill in valid
'To' and 'From' address, and change the SMTP server from 'localhost'
to what you normally use/need to use.

Second, I used Novell GroupWise and Sylpheed as the email clients. As
stated in the MIME::Lite and MIME::Lite::HTML documentation and proven
during my tests, each client will handle email attachments
differently. Plus, you will notice I tried to add text to the
begining of the email - which was the only thing that showed properly
in the email clients. So, I commented the lines out. The code will
produce inline HTML AND attachments. However, I was not able to test
using Outlook.

I personally want to get this working properly, because I would like
to use this in work I do. I'll post anything else I know here -and- I
might just email the author to see if the usage is correct -and-
double check the RFC's to see if the output produced and what the
RFC's jive. So far, they do.

I didn't use the MIME::Lite::HTML module because that only produces
inline HTML. From the OP, it appears that you wanted an attachment.
I also used LWP and HTML::TokeParse to gather the original document.
The code is commented for you (and any one else's) review.

HTH

Jim

==TESTED, BUT NEEDS VARIABLES UPDATED==
#!/usr/bin/perl -w

#use strict pragma
use strict;

#use the following modules
use LWP::Simple;
use HTML::TokeParser;
use MIME::Lite;

#declare lexical variables (I do it right Tad? )
my ($directory,$text,$html,$parser,%images,$mimeLite) ;

#what directory are file files located
$directory = '<fill in directory here>';

#set the text (aka body) of message
$text = 'Here is the latest add for ....';

#get the HTML document (as if you were using a browser) using LWP
#notice the 'file://' - this is the same as if you typed in
#file:///<some directory>/<some file>
$html = get("file://$directory/index.htm");

#declare a new HTML::TokeParser object - use the HTML file
#you just got as the document to parse
$parser = HTML::TokeParser->new(\$html);

#while parsing through the document, get each token
#(aka tag w/ attributes)
while (my $token = $parser->get_token) {
#if the tag is a start tag AND is the 'img' tag ....
if ($token->[0] eq 'S' && $token->[1] eq 'img') {
#store the 'src' attribute (aka the image file name)
#in the hash %images
$images{ $token->[2]{'src'} }++;
}
}

#this will allow MIME::Lite to verify the address you're sending to
$MIME::Lite::AUTO_VERIFY=1;

#create a new MIME::Lite object with
#the following attributes
#The 'Reply-To' is NOT required, but nice in case this script
#runs as a daemon/service - if you set this, when a user
#clicks the 'Reply', the 'Reply-To' address is used instead of
#the 'From' address
$mimeLite = new MIME::Lite(
From=>'FROM',
To=>'TO',
Subject=>'TEST',
Type=>'multipart/related',
'Reply-To'=>'RELPY-TO',
);

#THIS PART DOES NOT WORK PROPERLY
#Now, start building your MIME encoded attachments
#First, attach the body ...
#$mimeLite->attach(
# Type=>'text/plain',
# Data=>"$text",
# Encoding=>'quoted-printable'
#);

#now, the images ...
foreach my $img(keys %images){
#now, put $img into $new_img
my $new_img = $img;
#this regex removes the leading '/' from the filename
#it may NOT be required - it was for my test
$new_img =~ s/^\///;

#get rid of any path information - just get the filename
$new_img =~ s/^.*[\/](\w+\.\w+)$/$1/;

#according to the MIME::Lite documentation, in order to get
#any images to show up, we need to insert 'cid:' into the
'src'
#tag - we'll to that here for each image with a regex
$html =~ s/\"$img\"/\"cid:$new_img\"/g;

#now create the attachment ...
$mimeLite->attach(
Type=>'image/gif',
Path=>"$directory/$img",
Id=>"$new_img",
Encoding=>'base64',
Disposition=>'attachment',
Filename=>"$new_img"
);
}

#now, attach the HTML file ...
#for your purposes, you may want to change the 'Type' to
#what was suggested in the previous post and the 'Encoding'
#could be removed if you do that or changed to
#'base64'
$mimeLite->attach(
Type=>'text/html',
Data=>"$html",
Encoding=>'quoted-printable',
Disposition=>'attachment',
Filename=>'myhtml.htm'
);

#send the message
$mimeLite->send('smtp', 'localhost');
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      08-29-2003
On Fri, 29 Aug 2003 04:28:28 GMT
"William Alexander Segraves" <(E-Mail Removed)> wrote:
> "Jane Humbrey" <(E-Mail Removed)> wrote in message
> news:ZjT2b.128239$(E-Mail Removed)...
> > G'day. How can we show the attachment clip sign in receiver's
> > inbox?. Currently the receiver actually receive the attchment, but
> > it won't show

> up
> > as a clip sign in Outlook/Outlook Express. Many people can't
> > recognize the attachment, because it won't show up as a paper clip
> > sign.

>
> Your problem does not appear to be a Perl problem.
>
> You should get the receiver to do this: In Outlook Express, do "View
> + Columns" and check the Attachment Checkbox. Then move the
> Attachment Column(Checkbox) to the position (order) he/she desires.
>
> If the Attachment Checkbox is not selected at the client end, why
> would you expect the receiver to be able to see the paper clip
> symbol?


Yes and no.

The MIME::Lite module allows you to send attachments,
which, if it's just one, should show up fine in any email client.

MIME::Lite::HTML however sends the HTML file as an inline HTML -
no attachment.

So, without being there to see first hand what's going
on, you could be right -or- I could have a point about what I just
said - having spent a few hours trying to get either to do what I
wanted them to do and using two clients other than Outlook.

Have a go at the code I posted and let me know your results - okay?
I'm curious to see what the outcome is.

---
Jim
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      08-30-2003
"Jane Humbrey" <(E-Mail Removed)> wrote in message news:<85x3b.130648$(E-Mail Removed)>...
> Hi James
>
> Thanks for your code. I changed all details as you said. The script was run
> OK. But the output was an email with all were attachments(html file,image
> file, word file). The paper clip didn't show up in the Outlook/Outlook
> Express. I really want the html and the image should be in the message in
> correct places. I want to attach only a word file as attachment and the
> paper clip sign to be shown in the receiver's inbox. Thank you once again
> for your help.
>
> Cheers
> Jo


Bill Segraves posted a suggestion as well - maybe you should give that
a shot and see what happens. I'm begining to believe as Bill does
that this is not a Perl issue. If the MIME encoding is correct
(which, as far as I can tell from the code I posted previously is),
that the issue resides with the usage of the email client. Sorry

Jim
 
Reply With Quote
 
Jane Humbrey
Guest
Posts: n/a
 
      09-01-2003
Hi Guys

Thanks for all your suggestions. I checked the attachment tick in the
view -->columns but it was there already. The checked from my desktop by
sent mails to my own address/Outlook. I am using the command line interface
to run my mailing perl script from my destop(like 'perl myscript.pl').
Surprisingly if I send an attachment using the outlook express to my own
address the clip sign is there, but if I use the perl script from my
commandline I can't see the attchment sign in the received mail. My full
code is as follows:

use strict;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;
use MIME::Lite::HTML;
use MIME::Lite;

my $mailHTML = new MIME::Lite::HTML
From => "dbcoordinator\@cs.org.au",
To => "$receiver",
Subject => "Credit details attached";

my $MIMEmail = $mailHTML->parse("file://C|/test/coverpage/coverexec.htm");
$MIMEmail->attach(
Type => 'application/msword',
Path =>'Sol.doc' ,
Filename => 'Sol.doc' ,
Disposition => 'attachment'

);
$MIMEmail->send_by_smtp('smtp.gforce.co.au');
print header,"Mail envoye (","Mail sent to" , " to ",
"$receiver",")<<<<<<<<\n\n\n";

print "You mailing job has been finished by me!! Thanks!!";

You can try the above code from your windows commandline. Anyway thank you
very much guys. I really appreciate your time and help.

Cheers
Jo



"William Alexander Segraves" <(E-Mail Removed)> wrote in message
news:9TJ3b.528$(E-Mail Removed) k.net...
> "James Willmore" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ...
> > On Fri, 29 Aug 2003 04:28:28 GMT
> > "William Alexander Segraves" <(E-Mail Removed)> wrote:

> <snip>
> > > Your problem does not appear to be a Perl problem.
> > >
> > > You should get the receiver to do this: In Outlook Express, do "View
> > > + Columns" and check the Attachment Checkbox. Then move the
> > > Attachment Column(Checkbox) to the position (order) he/she desires.
> > >
> > > If the Attachment Checkbox is not selected at the client end, why
> > > would you expect the receiver to be able to see the paper clip
> > > symbol?

> >
> > Yes and no.
> >

>
> I tested my advice on Outlook Express 5.5 before responding. The paper

clip
> does not show up if the Attachment Checkbox is not checked.
>
> > The MIME::Lite module allows you to send attachments,
> > which, if it's just one, should show up fine in any email client.
> >

>
> Indeed, the attachment should show, but the paper clip will not show in

the
> client unless the Attachment Checkbox is checked in "View + Columns", as
> well as moved into the view.
>
> > MIME::Lite::HTML however sends the HTML file as an inline HTML -
> > no attachment.
> >
> > So, without being there to see first hand what's going
> > on, you could be right -or- I could have a point about what I just
> > said - having spent a few hours trying to get either to do what I
> > wanted them to do and using two clients other than Outlook.
> >

>
> Can't help here, as I don't have Outlook, either. My advice applies to
> Outlook Express.
>
> > Have a go at the code I posted and let me know your results - okay?
> > I'm curious to see what the outcome is.
> >

>
> OP, are you still with us? I looked at several examples I had created with
> MIME::Lite. If I toggle Attachment checkbox to 'Unchecked', the paper clip
> disappears. If I toggle Attachment Checkbox to 'Checked', the paperclip
> appears.
>
> > ---
> > Jim

>
> Thanks, Jim. I hope the OP is still with this. I don't see a Perl issue,

so
> I'm out of here.
>
> Cheers.
>
> Bill Segraves
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plus sign not shown souporpower@gmail.com Javascript 5 10-17-2008 02:50 PM
Double.ToString("C") cause web page display problem: "$" sign does not shown properly. Norman Yuan ASP .Net 0 01-26-2006 10:59 PM
Why paper clip shows in OE and no attachment Ockerr Computer Support 2 01-27-2005 08:12 PM
How do I post a large attachment (film clip) to Usenet Treb Computer Support 2 11-21-2003 07:19 AM
NOT SHOWN. The page is not shown until refresh it ! Mete Akalın ASP General 1 07-25-2003 11:28 AM



Advertisments