如何通过Web API将电子邮件添加为机会中的活动

时间:2016-07-08 22:19:21

标签: c# acumatica

我试图将电子邮件添加到机会中作为使用web api的活动之一,以下是我尝试过的代码:

            CR304000Content CR304000 = context.CR304000GetSchema();
            context.CR304000Clear();

            List<Command> cmds = new List<Command>();

            cmds.Add(new Value { Value = opportunity.ID, LinkedCommand = CR304000.OpportunitySummary.OpportunityID, Commit = true });
            cmds.Add(new Value { Value = "Draft", LinkedCommand = CR304000.Activities.MailStatus});
            cmds.Add(new Value { Value = "Email", LinkedCommand = CR304000.Activities.Type});
            cmds.Add(new Value { Value = email.Subject, LinkedCommand = CR304000.Activities.Summary });
            cmds.Add(new Value { Value = email.Message, LinkedCommand = CR304000.Activities.NoteText });

            cmds.Add(CR304000.Actions.Save);

代码没有给我错误,但是,在我运行代码之后,我得到了一个“注释”,而不是电子邮件,在这个机会下添加到“活动”中。

有人可以给我一些线索,将电子邮件(草稿)添加到作为活动的机会中吗?因为我可以手动转到“组织” - &gt; “客户管理” - &gt; “机会”并单击“活动”选项卡,然后单击“添加电子邮件”按钮将电子邮件(草稿)添加到商机中,我假设我应该能够通过网络API执行相同的操作...

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

请参阅以下代码段,将电子邮件草稿添加到现有商机中。

<!-- language: c# -->
//Opportunity Screen
CR304000Content CR304000 = context.CR304000GetSchema();
context.CR304000Clear();

//Email Activity Screen
CR306015Content CR306015 = context.CR306015GetSchema();
context.CR306015Clear();

//Locate Opportunity for which Email Draft needs to be added
CR304000Content[] CR304000result = context.CR304000Submit(
    new Command[]
    {                                        
        new Value { Value = "000007", LinkedCommand = CR304000.OpportunitySummary.OpportunityID, Commit = true},
        //Invoke New Email Actity Action
        CR304000.Actions.NewMailActivity
    });

//Specify data for Email Activity
CR306015Content[] CR306015result = context.CR306015Submit(
    new Command[] 
        {                    
            new Value { Value = "Subject 7", LinkedCommand = CR306015.Message.Subject },
            new Value { Value = "Notes Addition 7", LinkedCommand = CR306015.Message_.ActivityDetails},
            CR306015.Actions.Save
        });