Is it possibile to to use "raw_source" Argument (POST /Emails Rest API / Archive) to upload existing .eml mail file?

Hello,

I'm trying to archive in SugarCRM a email message saved as .eml File.

Can I used the raw_source arguments inside Rest API POST /Emails "archive" to populate email fields inside SugarCRM?

I tried to upload directly the eml file (using postman): the post command return the id of new mail record:

{
    "id""5423b794-de05-11ed-b35e-0242ac120003",
    "date_entered""2023-04-18T18:23:18+02:00",
    "date_modified""2023-04-18T18:23:18+02:00",
    "assigned_user_id""387323fc-adf1-11ed-8274-0242ac120004",
    "assigned_user_name""besttool",

....

but the fields in SugarCRM was not populated by the content of EML /raw_code.

is there an example of how to use the raw_code argument?

Thank in advance,

Best Regards,

Vincenzo

Parents
  • Hello

    The   POST /Emails Endpoint can be used to archive emails via API but it does expect the content of the email to be inserted in the field description_html and the subject of the email in the field name. 

    You can take the following request from our documentation as an example approach. 

    {
      "state": "Archived",
      "name": "Re: Discuss Proposal",
      "description": "Now is a good time",
      "description_html": "<p>Now is a good time</p>",
      "date_sent": "2012-02-17T06:53:00-08:00",
      "message_id": "<d9c165d0-8863-ba61-dc85-51ed8016c476@example.com>",
      "assigned_user_id": "9c61c46a-a7c5-df71-481c-51d48232f820",
      "parent_type": "Leads",
      "parent_id": "f6a0611a-7d27-11e7-9d70-3c15c2d582c6",
      "team_name": [{
        "id": "1",
        "display_name": "Global",
        "name": "Global",
        "name_2": "",
        "primary": true,
        "selected": false
      }],
      "from": {
        "create": [{
          "parent_type": "Leads",
          "parent_id": "f6a0611a-7d27-11e7-9d70-3c15c2d582c6"
        }]
      },
      "to": {
        "create": [{
          "parent_type": "Users",
          "parent_id": "9c61c46a-a7c5-df71-481c-51d48232f820"
        }]
      },
      "cc": {
        "create": [{
          "parent_type": "Contacts",
          "parent_id": "79b9c194-7d79-11e7-8fc5-3c15c2d582c6"
        }, {
          "parent_type": "Users",
          "parent_id": "79c2e800-7d79-11e7-84af-3c15c2d582c6"
          "email_address_id": "79cc341e-7d79-11e7-8748-3c15c2d582c6"
        }]
      },
      "bcc": {
        "create": [{
          "email_address_id": "ac804842-7d78-11e7-a809-3c15c2d582c6"
        }]
      },
      "attachments": {
        "create": [{
          "filename_guid": "afe9702e-53a3-0efb-6bbe-56c3580885ef",
          "name": "Quote.pdf",
          "filename": "Quote.pdf"
        }]
      }
    }



    Can you share the request that you are performing so we can have a better understanding of what you are doing? 

    Cheers, 

    André

  • Hello Andre,

    Thank you for your reply.

    I have mail message saved as .eml file (that can include attachments,  all Headers, Subject, HTML Body of message, , etc) and I need to archive it to SugarCRM.

    I'm just curious about the option "raw_source" in the POST/Emails, if is possibile to use this field to upload entire message (and save time in writing code)

    Otherwise I follow your suggestions  , but I need to parse EML and populate every single item (subject,  description_html, from, to, attachments, etc..)

    Cheers,

    Vincenzo

  • Hi

    Checking Sugar code I can see that the raw_source field is used to handle emails that are imported via IMAP in the inbound mailboxes. 

    I do not believe this will work if you populate the field via API request.
    If you want to have a look at the code check the function getFormattedRawSource in 

    SugarEnt/modules/InboundEmail/InboundEmail.php

    I hope this helps. 

    André 

Reply Children
No Data