By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

Sending Email with Inline Images

P: 3
hi all -

I have been tasked to send customized emails to a set of users based on a certain condition in my company. ( This is NOT SPAM )

I have used MIME::Lite successfully to send html templates as emails. the users in my company are Outlook users. But for some reason my emails sometimes reach the Junk E-Mail folder( I am sending using my own company issued email address )

Here's the code I currently use:
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use diagnostics;
  4. use MIME::Lite;
  5. sub send_email()
  6. {
  7. open my $fh ,"data/address.txt" or die "Cannot open file:$!\n";
  8. my @filename =&fileread('htmlcode.htm');
  9. while(<$fh>)
  10. {
  11.     chomp;
  12.     my $msg = MIME::Lite->new( From =>"user\@host\.com",
  13.                                To =>$_,
  14.                                Subject =>"Action Required! Complete your Registration",
  15.                                Disposition =>'inline',                 
  16.                                Type    =>'multipart/related');
  17. $msg->attach(Type => 'text/html', Data => qq{@filename});
  18. $msg->attach(Type => 'image/gif',Id => 'img1.jpg',
  19.              Path => "images/img1.jpg");
  20. $msg->attach(Type => 'image/gif',Id => 'img2.gif',
  21.              Path => "images/img2.gif");
  22. $msg->attach(Type => 'image/gif',Id => img3.gif',
  23.              Path => "images/img3.gif");
  24. $msg->send("sendmail","/usr/sbin/sendmail -t");
  25. }
  26. close $fh;
  27. }
  28. &send_email(); 
The html is currently slurped into an array by the subroutine &fileread. the attachments in MIME::Lite are referred as 'cid:img2.gif...etc ' in the html templates.

Is there anyway to avoid the routing to the Junk mail folder in microsoft outlook ?

Thanks,
Santhosh
Dec 4 '07 #1
Share this Question
Share on Google+
6 Replies


KevinADC
Expert 2.5K+
P: 4,059
As far as I know the answer is no unless you know why Outlook considers the email as junk, then you can change the subject line (or whatever needs changing) to avoid the dump into the junk folder.
Dec 5 '07 #2

P: 3
KevinADC -
Thanks for the quick response ! Turns out there was a tag that wasn't compatible with Outlook that makes it mark as Junk E-mail.

Santhosh
Dec 6 '07 #3

eWish
Expert 100+
P: 971
What tag was it that was not compatible?

--Kevin
Dec 7 '07 #4

P: 3
[HTML]<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
.style2 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>[/HTML]

After removing this tag, the messages came through perfectly.

Santhosh
Dec 7 '07 #5

P: 1
HI SSankar,
I was about to post this same thing in this forum and saw that you have already posted that. I am trying to make this work for a long time but no luck. Everytime it mails either as attachment or in mail body but without images.
As you said you have sorted it out can you please lend you help on this.
I am using linux for this. Users will send mail in a particular user account and .procmailrc will generate auto reply for that user with some html files with images based on subject of the mail.

Please help on this. Waiting for your kind response. Thanks in advance.
Dec 12 '07 #6

KevinADC
Expert 2.5K+
P: 4,059
HI SSankar,
I was about to post this same thing in this forum and saw that you have already posted that. I am trying to make this work for a long time but no luck. Everytime it mails either as attachment or in mail body but without images.
As you said you have sorted it out can you please lend you help on this.
I am using linux for this. Users will send mail in a particular user account and .procmailrc will generate auto reply for that user with some html files with images based on subject of the mail.

Please help on this. Waiting for your kind response. Thanks in advance.
As SSankar said in the first post, they are using MIME::Lite, that is what you can do also. The problem SSankar had was the mail ended up in Outlooks junk folder, not adding images.
Dec 12 '07 #7

Post your reply

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