コード例 #1
0
        public static bool UploadAttahcment(clsEmailAttachments objAttachment, string email_id)
        {
            string strUserID = clsSuiteCRMHelper.GetUserId();

            if (strUserID == "")
            {
                SuiteCRMUserSession.Login();
            }
            //Initialize AddIn attachment
            List <RESTObjects.eNameValue> initNoteData = new List <RESTObjects.eNameValue>();

            initNoteData.Add(new RESTObjects.eNameValue()
            {
                name = "name", value = objAttachment.DisplayName
            });

            object initNoteDataWebFormat = new
            {
                @session         = SuiteCRMUserSession.id,
                @module_name     = "Notes",
                @name_value_list = initNoteData
            };
            var res = clsGlobals.GetResponse <RESTObjects.eNewSetEntryResult>("set_entry", initNoteDataWebFormat);

            //upload the attachment
            RESTObjects.eNewNoteAttachment attachment = new RESTObjects.eNewNoteAttachment();
            attachment.ID         = res.id;
            attachment.FileName   = objAttachment.DisplayName;
            attachment.FileCotent = objAttachment.FileContentInBase64String;

            object attachmentDataWebFormat = new
            {
                @session = SuiteCRMUserSession.id,
                @note    = attachment
            };

            var attachmentResult = clsGlobals.GetResponse <RESTObjects.eNewSetEntryResult>("set_note_attachment", attachmentDataWebFormat);

            //Relate the email and the attachment
            object contacRelationshipData = new
            {
                @session         = SuiteCRMUserSession.id,
                @module_name     = "Emails",
                @module_id       = email_id,
                @link_field_name = "notes",
                @related_ids     = new string[] { attachmentResult.id }
            };
            var rel = clsGlobals.GetResponse <RESTObjects.eNewSetRelationshipListResult>("set_relationship", contacRelationshipData);

            if (rel.Created == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public static void UploadAttachment(clsEmailAttachments objAttachment, string email_id)
        {
            EnsureLoggedIn();

            object initNoteDataWebFormat = new
            {
                @session         = SuiteCRMUserSession.id,
                @module_name     = "Notes",
                @name_value_list = new List <RESTObjects.eNameValue>
                {
                    new RESTObjects.eNameValue()
                    {
                        name = "name", value = objAttachment.DisplayName
                    }
                }
            };
            var res = SuiteCRMUserSession.RestServer.GetCrmResponse <RESTObjects.eNewSetEntryResult>("set_entry", initNoteDataWebFormat);

            //upload the attachment
            RESTObjects.eNewNoteAttachment attachment = new RESTObjects.eNewNoteAttachment();
            attachment.ID         = res.id;
            attachment.FileName   = objAttachment.DisplayName;
            attachment.FileCotent = objAttachment.FileContentInBase64String;

            object attachmentDataWebFormat = new
            {
                @session = SuiteCRMUserSession.id,
                @note    = attachment
            };

            var attachmentResult = SuiteCRMUserSession.RestServer.GetCrmResponse <RESTObjects.eNewSetEntryResult>("set_note_attachment", attachmentDataWebFormat);

            //Relate the email and the attachment
            object contacRelationshipData = new
            {
                @session         = SuiteCRMUserSession.id,
                @module_name     = "Emails",
                @module_id       = email_id,
                @link_field_name = "notes",
                @related_ids     = new string[] { attachmentResult.id }
            };
            var rel = SuiteCRMUserSession.RestServer.GetCrmResponse <RESTObjects.eNewSetRelationshipListResult>("set_relationship", contacRelationshipData);

            if (rel.Created == 0)
            {
                throw new CrmSaveDataException("Cannot upload email attachment ('set_relationship failed')");
            }
        }
コード例 #3
0
        public static bool UploadAttahcment(clsEmailAttachments objAttachment, string email_id)
        {
            string strUserID = clsSuiteCRMHelper.GetUserId();
            if (strUserID == "")
            {
                SuiteCRMUserSession.Login();
            }
            //Initialize AddIn attachment
            List<RESTObjects.eNameValue> initNoteData = new List<RESTObjects.eNameValue>();
            initNoteData.Add(new RESTObjects.eNameValue() { name = "name", value = objAttachment.DisplayName });

            object initNoteDataWebFormat = new
            {
                @session = SuiteCRMUserSession.id,
                @module_name = "Notes",
                @name_value_list = initNoteData
            };
            var res = clsGlobals.GetResponse<RESTObjects.eNewSetEntryResult>("set_entry", initNoteDataWebFormat);

            //upload the attachment
            RESTObjects.eNewNoteAttachment attachment = new RESTObjects.eNewNoteAttachment();
            attachment.ID = res.id;
            attachment.FileName = objAttachment.DisplayName;
            attachment.FileCotent = objAttachment.FileContentInBase64String;

            object attachmentDataWebFormat = new
            {
                @session = SuiteCRMUserSession.id,
                @note = attachment
            };

            var attachmentResult = clsGlobals.GetResponse<RESTObjects.eNewSetEntryResult>("set_note_attachment", attachmentDataWebFormat);

            //Relate the email and the attachment
            object contacRelationshipData = new
            {
                @session = SuiteCRMUserSession.id,
                @module_name = "Emails",
                @module_id = email_id,
                @link_field_name = "notes",
                @related_ids = new string[] { attachmentResult.id }
            };
            var rel = clsGlobals.GetResponse<RESTObjects.eNewSetRelationshipListResult>("set_relationship", contacRelationshipData);

            if (rel.Created == 0)
            {
                return false;
            }
            return true;
        }