Send e-mail with various attachments

Asked

Viewed 259 times

3

I am sending e-mail through the INDY, the email is being sent and the attachment is going, but as it appears in the code below, I do a go through all the attachments, and it only sends the last, someone knows what is wrong?

    if pAnexo.Count > 0 then
    begin
      for i := 0 to pAnexo.Count - 1 do
      begin
          vIdAttachmentFile.Create(vIdMessage.MessageParts, pAnexo.Strings[i]);
      end;
    end;

The variable pAnex is an array of files that will be attached, I’m trying to send a jpeg and an xml, in the future I want to send a PDF together.

  • 1

    I’m looking at an example that works, the difference I saw, is that instead of a variable is straight from the class like this: TIdAttachmentFile.Create...

  • 1

    Bah, thank you so much! It worked like this!

2 answers

2


Below follows the way it worked for me, it was just a detail! Melissa helped me: /users/111325/melissa

if pAnexo.Count > 0 then
begin
  for i := 0 to pAnexo.Count - 1 do
  begin
      TIdAttachmentFile.Create(vIdMessage.MessageParts, pAnexo[i]);
  end;
end;

0

I believe that the pAnexo be a stringList, otherwise, change. And then pass this way:

vIdAttachmentFile.Create(vIdMessage.MessageParts, pAnexo[i]);

Another thing, check the ContentType:

vIdMessage.ContentType := 'multipart/mixed';
  • It didn’t work like that, keep sending only the last file

  • What a pity :/ I can’t test at the moment :/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.