TIdAttachmentFile Indy

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

TIdAttachmentFile Indy

Postby Lena » Tue May 31, 2016 7:47 am

How to attach a file?
Code: Select all
//Encoding=meMIME
   #if defined(_PLAT_IOS) || defined(_PLAT_ANDROID)
       String att = System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetDocumentsPath
       (), "mikros.s3db");
      #endif
      std::unique_ptr<TIdAttachmentFile> attachment(new    TIdAttachmentFile(IdMessage1->MessageParts, att));
attachment->FileName = "mikros.s3db";
      IdSMTP1->Connect();
      IdSMTP1->Send(IdMessage1);

I want to get the file attached to the letter.
However, I get a plain text file instead... ->
This is a multi-part message in MIME format --etfJoonZtXd5yJMYHXX2ZcRXLT=_jbToBM Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =CE=F2: =D4=E5=E4=FF --etfJoonZtXd5yJMYHXX2ZcRXLT=_jbToBM Content-Type: application/octet-stream; name="mikros.s3db" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="mikros.s3db" U1FMaXRlIGZvcm1hdCAzAAQAAQEAQCAgAAAApAAAAAQAAAAAAAAAAAAAACYAAAABAAAAAAAAAAAA AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACkAC3p6g0AAAABAxwAAxwDHAAA
e.t.s.
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdAttachmentFile Indy

Postby Lena » Tue May 31, 2016 8:51 am

I try:
Code: Select all
      std::unique_ptr<TIdAttachmentFile> attachment(new TIdAttachmentFile(IdMessage1->MessageParts, att));
      attachment->ContentType = "multipart/mixed";
//attachment->ContentDisposition = "attachment";
      attachment->ContentDisposition = "inline";
                 attachment->ContentID = "mikros.s3db";
      attachment->DisplayName = "mikros.s3db";
      attachment->ParentPart = 1;


No result
This is a multi-part message in MIME format --ycp2GcEgRjsp=_MN46pvCSHSUNpeq7X7M7 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =CE=F2: =D1=E0=F8=E0 --ycp2GcEgRjsp=_MN46pvCSHSUNpeq7X7M7 Content-Type: multipart/mixed; boundary="vdjlC6dmkmgI6=_Q7ybuHGDqSzEGHy5Sr3" --vdjlC6dmkmgI6=_Q7ybuHGDqSzEGHy5Sr3-- --ycp2GcEgRjsp=_MN46pvCSHSUNpeq7X7M7--
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdAttachmentFile Indy

Postby rlebeau » Tue May 31, 2016 5:42 pm

Lena wrote:How to attach a file?


You already know the answer to that, because you are already doing it.

And BTW, TIdMessage takes ownership of the TIdAttachmentFile, so you should not be using std::unique_ptr at all (though it does not hurt anything if you do).

Lena wrote:How to attach a file?
I want to get the file attached to the letter.
However, I get a plain text file instead... ->


No, you don't. Your example clearly shows a properly attached file in the email body. But, what you didn't show is the complete email, especially the top-level headers, so I can't see if you setup the rest of the TIdMessage correctly or not. If the email is not appearing correctly on the recipient's end, then the email is likely malformed, and thus TIdMessage is likely being misconfigured. Please show all of your code for setting up the TIdMessage, and what the resulting email actually looks like.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: TIdAttachmentFile Indy

Postby rlebeau » Tue May 31, 2016 5:49 pm

Lena wrote:
Code: Select all
      std::unique_ptr<TIdAttachmentFile> attachment(new TIdAttachmentFile(IdMessage1->MessageParts, att));
      attachment->ContentType = "multipart/mixed";



Setting an attachment's ContentType to a "multipart/..." value is the completely wrong thing to do (if you want to create MIME encoded emails that have nested MIME parts, use TIdText instead for "multipart/..." parts). The ContentType needs to be the actual media type of the file being attached, or "application/octet-stream" if the media type is not known.

That "multipart/mixed" value would be more appropriate in the TIdMessage::ContentType property instead, such as when you have added a TIdText for text and a TIdAttachmentFile for an unrelated attachment.

Lena wrote:
Code: Select all
//attachment->ContentDisposition = "attachment";
      attachment->ContentDisposition = "inline";



That is also a wrong setting for this kind of attachment ("inline" usually only makes sense for images and other types of data that can be rendered directly in an email viewer).

Lena wrote:
Code: Select all
      attachment->ParentPart = 1;



That only makes sense to do if the Item at index 1 of the TIdMessage::MessageParts collection were a "multipart/..." part, and the attachment is to be a child of that item. Such as when creating an HTML formatted email. But even then, index 1 would not be the likely ParentPart value for any attachment.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: TIdAttachmentFile Indy

Postby Lena » Wed Jun 01, 2016 5:56 am

Please show all of your code for setting up the TIdMessage, and what the resulting email actually looks like.


My code now:
Code: Select all
//try attach mikros.s3db SQLlite file
try
  {
    try
      {
      //if add attachment no russian in body
                //=CE=F2: =CC=F3=F1=FF
      IdMessage1->Body->Text = L"От: " + Edit2->Text;

                 //SysLocale.PriLangID = LANG_RUSSIAN;//error
      //here problem Subject=???????
      IdMessage1->Subject = L"База данных 2"; //<- test

      TIdEMailAddressItem *Item = IdMessage1->Recipients->Add();
      Item->User = Edit3->Text;
      Item->Domain = L"yandex.ru";

      #if defined(_PLAT_IOS) || defined(_PLAT_ANDROID)
       String att = System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetDocumentsPath
       (), "mikros.s3db");
      #endif
      
      std::unique_ptr<TIdAttachmentFile> attachment(new TIdAttachmentFile(IdMessage1->MessageParts, att));
      attachment->ContentType = "application/octet-stream";

      Button3->Enabled = false;
      IdSMTP1->Connect();
      IdSMTP1->Send(IdMessage1);
      Button3->Enabled = true;
          
      }
      catch (EIdException &E)
      {
           //      
      }

  }
  __finally
       {
        Button3->Enabled = true;
        if(IdSMTP1->Connected())
          {
           IdSMTP1->Disconnect();
                  }
                 }


I got this email:
This is a multi-part message in MIME format

--7P=_eo9s3TXEWUv6rRBmyPObOj1EWkpRpL
Content-Type: text/plain; charset="windows-1251"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

=CE=F2: =CC=F3=F1=FF

--7P=_eo9s3TXEWUv6rRBmyPObOj1EWkpRpL
Content-Type: application/octet-stream;
name="mikros.s3db"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="mikros.s3db"

U1FMaXRlIGZvcm1hdCAzAAQAAQEAQCAgAAAAyAAAAAYAAAAAAAAAAAAAACYAAAABAAAAAAAAAAAA
AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAC3p6g0AAAABAxwAAxwDHAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7hdPTwGCRXRh
YmxlbG9nYmVhY29uX0FMVEVSX0JBQ0tVUF8xNDY0Njk0MTYxbG9nYmVhY29uX0FMVEVSX0JBQ0tV
UF8xNDY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LfQvtC90YswMS4wNi4xNkgpBwAvAy81HTQ2OjlDOjMzOjM5Ojc3OjNCAJqD
MDEuMDYuMTYgMTE6NDI6NDnQktGF0L7QtCDQsiDQt9C+0L3RgzAxLjA2LjE2

--7P=_eo9s3TXEWUv6rRBmyPObOj1EWkpRpL--
Attachments
att.jpg
att.jpg (59.24 KiB) Viewed 3574 times
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdAttachmentFile Indy

Postby rlebeau » Wed Jun 01, 2016 12:33 pm

To include both text and attachment, set the TIdMessage::ContentType property to a suitable "multipart/..." type, in this case "multipart/mixed". You have the ContentType set to "text/plain" in the Object Inspector and are not overwriting that value in your code.

Lena wrote:I got this email


That is the email *body*, but you still have not shown the email *headers* that precede that body. If you look at those, you will see that the top-level Content-Type header is "text/plain", which is why your content does not work correctly. You need your "text/plain" and "application/octet-stream" parts wrapped inside of "multipart/mixed", not "text/plain".
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Bing [Bot] and 9 guests

cron