Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi / Indy. Problem with sending email with attachments

Posted on 2010-09-08
4
Medium Priority
?
2,123 Views
1 Endorsement
Last Modified: 2012-06-21
Good Day

I am having trouble with sending out emails with a pdf attachments. I am using wpdf to generate the pdf documents.

I create entries into a table and then I read one by one from the table and send the emails out with the attachments. Sometimes I can send 20 emails with the pdf attachment and I works 100%, but other times I get the emails with the following error : "Disposition: attachment".

I have included the body of the email.

Please advice what the problem is and how can I solve this. EMail-body.txt
1
Comment
Question by:henryreynolds
[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
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
briangochnauer earned 2000 total points
ID: 33627532
Try the code below; works for me on tens of thousands of clients it's running on.
function SendMailResults(const email:String):boolean;
var sendfile :string;
    IdSMTP1  : TIdSMTP;
    SentMsg  : TIDMessage;
    Attachment : TIdAttachmentfile;
    base :string;
const CRLF : string = #10#13;
begin

    IdSMTP1 := TIdSMTP.Create(self);
    Name := 'IdSMTP1';
    idSMTP1.Host := emailSMTPHost; //like '10.105.0.0';
    SentMsg := TIDMessage.Create(nil);

    with SentMsg do
      begin
        IsEncoded := True ;
        Encoding := meMIME;
        Subject :=  'PDF';
        Body.Add('PDF attached');
        From.address := emailSMTPFrom;//'ed at mail dot nl';
        Recipients.EMailAddresses := email;//'jk at them dot nl';
      end;

    sendfile := 'c:\yourfile.pdf';
    if FileExists(SendFile) then
     begin
       Attachment := TIdAttachmentfile.Create(SentMsg.MessageParts,SendFile);
//      Attachment.ContentDisposition := 'attachment';
//      Attachment.ContentType := 'text/xml';
       Attachment.FileName := SendFile;
     end;

  try
    try
      idSMTP1.Connect;
      idSMTP1.Send(SentMsg) ;
    except on E:Exception do
      ShowMessage('ERROR: ' + E.Message);
    end;
  finally
    if idSMTP1.Connected then idSMTP1.Disconnect;
  end;
end;

Open in new window

1
 

Author Comment

by:henryreynolds
ID: 33644204
Hi

I have tried your example but I still get sometimes the same error message.

Please help
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 33645621
I would check the smtp server for errors or maybe your client is decoding the message incorrectly.
Your 'email-body.txt' file reminds me of client side problems I have had.
0
 

Author Closing Comment

by:henryreynolds
ID: 33768640
done
0

Featured Post

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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