Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi All, I am trying to add an attachment file in mail i have set a MailAttachmectTransfer in MailTra

Options
U01J3GPTA1H
U01J3GPTA1H Posts: 43 🧑🏻‍🚀 - Cadet

Hi All,
I am trying to add an attachment file in mail i have set a MailAttachmectTransfer in MailTransfer with all require details like attachmentUrl and all but its not adding the attachments into my emails any solution on this ?

Comments

  • U01SE4SRCU9
    U01SE4SRCU9 Posts: 68 🧑🏻‍🚀 - Cadet
    edited September 2021
    Options

    Make sure that your MailAttachmentTransfer has:

    ->setFileName($fileName)
    ->setAttachmentUrl($absolutePathWithFileName)
    ->setDisplayName($displayName);
    

    FileName should be the filename + extension only, without path (e.g. "this_file.rtf").
    AttachmentUrl should be fully qualified, so absolute path to file with filename and extension, all together (e.g. "/usr/johndoe/documents/this_file.rtf").
    DisplayName can be anything you want to have displayed for it.

    For me, this has worked.

  • U01J3GPTA1H
    U01J3GPTA1H Posts: 43 🧑🏻‍🚀 - Cadet
    Options

    I have configured the same, see.

    $attachment->setFileName('1-v.1.pdf');
    $attachment->setDisplayName('Sample File');
    $attachment->setAttachmentUrl('/data/data/DE/media/files/1-v.1.pdf');
    
  • U01SE4SRCU9
    U01SE4SRCU9 Posts: 68 🧑🏻‍🚀 - Cadet
    edited September 2021
    Options

    Do you really have "data" twice in the path? And is this really the absolute path, from the root (and not just the project's root)?

  • U01J3GPTA1H
    U01J3GPTA1H Posts: 43 🧑🏻‍🚀 - Cadet
    Options

    i want to add this file for that this path should work i guess

  • U01SE4SRCU9
    U01SE4SRCU9 Posts: 68 🧑🏻‍🚀 - Cadet
    Options

    Well, that's just one data. So /data/DE/media/files/1-v.1.pdf, maybe. But you'll need the path from / - and this on your screenshot doesn't look like the contents of /.

  • U01J3GPTA1H
    U01J3GPTA1H Posts: 43 🧑🏻‍🚀 - Cadet
    Options

    I have tried with just one data also but didn't work. attached full screenshot maybe helpful, and also when i am exporting files /data/data/export/... this path is working for that.

  • U01SE4SRCU9
    U01SE4SRCU9 Posts: 68 🧑🏻‍🚀 - Cadet
    Options

    Maybe try attaching that long path string that's next to extranet-project on this screenshot in front of /data ...? But if that won't work either than no further ideas on my part at the moment, I'm afraid.

  • U01J3GPTA1H
    U01J3GPTA1H Posts: 43 🧑🏻‍🚀 - Cadet
    Options

    Ok, Thanks for the help.

  • U01SE4SRCU9
    U01SE4SRCU9 Posts: 68 🧑🏻‍🚀 - Cadet
    Options

    yw