ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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

  • Creator
    Topic
  • #16406
    golriz.nourani
    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
  • #16444
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Hello.

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

    #21135
    adriwan_kenoby
    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.

    #21137
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    > 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:

    #21142
    adriwan_kenoby
    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.

    #21146
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    > 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.

    #21392
    adriwan_kenoby
    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 ?

    #21417
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    > 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.

    #23149

    Geoffroy Cochard
    Participant

    Hie,

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

    #34271
    golriz.nourani
    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)

You must be logged in to reply to this topic.