OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions automatic email with attachment

This topic contains 9 replies, has 4 voices, and was last updated by  golriz.nourani 6 years, 12 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #25109

    golriz.nourani
    Participant

    Hi everyone,
    I want to send a automatic email and it has attachment
    but I don’t find how should I set attachment ( which controller handle it)?
    could you help me?
    thanks a lot

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #25110

    Yevhen Shyshkin
    Participant

    Hello.

    Attachment can be uploaded via AttachmentManager, then can be transformed to EmailAttachment via EmailAttachmentTransformer, and finally attached to the body of your email.

    #25111

    adriwan_kenoby
    Participant

    @Yevhen Shyshkin

    The AttachmentManager::prepareRemoteFile() method return an instance of File… How to convert it into an Attachment ?
    This not work :

    Or

    Their is something that I have misunderstood.

    #25112

    Yevhen Shyshkin
    Participant

    > How to convert it into an Attachment ?
    You can create and persist Attachment as a regular entity – it simply shows relation between entity and file. After that you can attach it to email. Check this example:

    #25113

    adriwan_kenoby
    Participant

    @Yevhen Shyshkin

    I don’t need to save attachement in DB.

    Is it possible to just attach a file to an email and send it without save the attachment in DB.

    At the end I will make an email template but for the time it is usefull to just use Email model and set his params.

    Thanks and regards.

    #25114

    Yevhen Shyshkin
    Participant

    > Is it possible to just attach a file to an email and send it without save the attachment in DB.
    Yes, it is even easier – you just have to build appropriate EmailAttachment object and add it to your email. Use body of EmailAttachmentTransformer::oroToEntity as an example.

    #25115

    adriwan_kenoby
    Participant

    Sorry but I don’t understand how to proced.
    To much thing that i am not aware.

    What type of object must I pass to addAttachment() method ? An AttachmentEntity or an AttachmentModel.
    Have I to deal with both ? It’s seem to be a litlle complicated for just one such thing.
    Am I on the right way ?

    Then, have I make the model too ?

    #25116

    Yevhen Shyshkin
    Participant

    > What type of object must I pass to addAttachment() method ? An AttachmentEntity or an AttachmentModel.
    This method requires instance of Oro\Bundle\EmailBundle\Form\Model\EmailAttachment.

    > Have I to deal with both ?
    Depends on your case. If you don’t have this file stored in DB then probably you will not need entity, only model.

    > Am I on the right way ?
    Yes, direction is correct. :) I’d propose to check whether you need to prepare you file, because looks like you alredy have it uploaded, so you don’t need to do it again.

    #25117

    Geoffroy Cochard
    Participant

    Hie,

    Below my solution in Workflow\Action based on emailAttachmentTransformer service… if it can help you :

    #25118

    golriz.nourani
    Participant

    Dear Sir
    After one year again I face with auto email. your explanation and sample code were so usefull, thanks a lot.
    when I put email of user of system in bcc list (in backend), dialog of email show my email as below
    (کاربر)test@gmail.com
    language of system is fa_IR so “کاربر” is translation of “user” but when I want to send email, system say that email is not in right format
    what should I do?
    Thanks
    Golriz

Viewing 9 replies - 1 through 9 (of 9 total)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top