?
Solved

Delphi 2009 & Indy 10 email attachments

Posted on 2009-07-09
13
Medium Priority
?
2,531 Views
Last Modified: 2012-05-07
I am upgrading from Delphi 7 with Indy 9 to Delphi 2009 and Indy 10.

I get Indy to attach a document to a email but the recipient receives a email with the attachment names ATT????.Dat although I attached a PDF file. If the recipient save's this as a PDF file it is the correct file.

How can I get Indy to send the correct attachment name.
MSG.Clear;
        if tbEmPendAttachment.Value <> '' then
        begin
          l_attachment := MailDir + '\' + tbEmPendAttachment.Value;
          TIdAttachmentFile.Create(Msg.MessageParts,l_attachment);
        end;
        if tbEmPendAttachment2.Value <> '' then
        begin
          MailFile := TIdAttachmentFile.Create(Msg.MessageParts,
          tbEmPendAttachment2.Value);
          MailFile.DisplayName := Msg.Subject;
        end;
        MSG.From.Text := Trim(tbEmPendFrom.Value);
        MSG.ReplyTo.EMailAddresses := Trim(tbEmPendFrom.Value);
        MSG.Recipients.EMailAddresses := trim(tbEMPendTo.Value);
        MSG.Subject := tbEmPendSubject.Value;
        MSG.ReceiptRecipient.Text := tbEmPendFrom.Value;
        l_body := TStringList.Create;
        l_body.Text := tbEmPendNote.Value;
        MSG.Body.Assign(l_body);
        l_body.Free;
        SMTP.Send(Msg);

Open in new window

0
Comment
Question by:gerhard9121
[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
  • 5
13 Comments
 
LVL 14

Expert Comment

by:SteveBay
ID: 24812782
I had to solve the same issue but I don't remember exactly how I did it. I think it had something to do with AttachmentEncoding.

Try adding this line some where prior to making your attachment.
MSG.AttachmentEncoding  := 'MIME';
0
 

Author Comment

by:gerhard9121
ID: 24813050
Tried adding MSG.AttachmentEncoding  := 'MIME' but it still attaches a ATT?????.Dat
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 24813206
Well it did take a fair amount of trial and error on my part to figure it out.
Also may need to add:
MSG.Encoding := meMIME;
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:gerhard9121
ID: 24813371
MSG.Encoding := meMIME;

This makes no difference. Any other suggestion please
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 24813492
Have you tried setting:
MailFile.Filename := tbEmPendAttachment2.Value;
0
 

Author Comment

by:gerhard9121
ID: 24813945
I have changed my code but no luck so far
    l_attachment := MailDir + '\' + tbEmPendAttachment.Value;
    MailFile := TIdAttachmentFile.Create(Msg.MessageParts,l_attachment);
    MSG.Encoding := meMime;
    Mailfile.FileName := tbEmPendAttachment.Value;

Open in new window

0
 
LVL 14

Expert Comment

by:SteveBay
ID: 24814001
Sorry, I know I have gone through this same stuff but I cannot remember exactly what solved it for me. If I stumble accross it I will post.
0
 

Author Comment

by:gerhard9121
ID: 24814055
Thanks for your help sofar. I have been battling with this for a couple of days and require a solution urgently
0
 

Author Comment

by:gerhard9121
ID: 24868889
The problem is with the version of Indy10 distributed with Delphi 2009. I downloaded the latest Indy after deleting all older indy file and recompiled Indy. Everything went well but cant load the dclIndyProtocols package. According to Indy it is because I still have old Indy files but I have checked this and still think it is an error in their source code.
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 24869053
When you say "can't load dclIndyProtocols package" - what happens, an error?
When that happens it's usually a problem with the library path
0
 

Author Comment

by:gerhard9121
ID: 24876286
I receive the following errro:

'The procdure entry point @Idheadercoderindy@anitialization&qqrv could not be located in the dynamik link library IndyProtocals120.bplgerhardodendaal
 
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 2000 total points
ID: 25004641
Have you tried the fix here? :
http://blog.digivendo.com/2008/10/fix-indy-mail-attachments-filenames-lost-in-d2009/

also the error you got seems by old version of indy, try to delete indy, and all indy *.bpl from delphi lib and windows system32 folder, then try to install the newer one
0
 

Author Comment

by:gerhard9121
ID: 25011246
As I previously stated the problem was in teh version of Indy distributed with Delph 2009. I loaded the latest version of Indy but could not get the components to load. I bypassed this problem by creating them at runtime.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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