locked
add custom attribute to email RRS feed

  • Question

  • I am creating an email

    how do i add a custom attribute in a crm 4 workflow?
    Friday, August 14, 2009 1:58 PM

Answers

  • Hi.

    I beg a pardon.

    Correct code is following:

    email mail = new email();
    //fields filling
    Guid id = crmservice.Create(mail);

    DynamicEntity dmail = new DynamicEntity("email");
    dmail["emailid"] = new Key(id);
    dmail["new_customfield"] = blah;
    crmservice.Update(dmail);
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    • Marked as answer by T Bonz Friday, August 14, 2009 4:05 PM
    Friday, August 14, 2009 3:54 PM
    Moderator

All replies

  • Hi.

    Could you give your scenario? I don't understand task you want to perform.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Friday, August 14, 2009 2:00 PM
    Moderator
  • I have a workflow that sends out an email that i create in the workflow

    I have a custom field thats called new_customfield

    How do i get to something like this Email.new_customfield= blah

    Friday, August 14, 2009 2:03 PM
  • Hi.

    If this attribute is placed on the email from just open tab with this field and fill it, if not - open Additional fields tab and fill this attribute there.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Friday, August 14, 2009 2:07 PM
    Moderator
  • I am dynamically creating the email
    Friday, August 14, 2009 2:09 PM
  • Hi.

    If you dynamically create an email - use DynamicEntity to complete this task. For example:

    DynamicEntity mail = new DynamicEntity("email");
    mail["new_customfield"] = blah;
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Friday, August 14, 2009 2:10 PM
    Moderator
  • its just one field -- so there is no other way except to create a dynamic entity and create teh email that way.

    after i go crmservice.create(email)

    how do you send it?
    Friday, August 14, 2009 2:13 PM
  • After you create the email using dynamic entity. you can send it with below code using SendEmailRequest
    // Standard CRM Service Setup
    CrmService service = new CrmService();
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

    CrmService service = new CrmService();
    service.Credentials =
        System.Net.CredentialCache.DefaultCredentials;

    // Get the ID of the system user.
    WhoAmIRequest userRequest = new WhoAmIRequest();
    WhoAmIResponse user =
        (WhoAmIResponse) service.Execute(userRequest);

    // Specify the system user who is sending the message.
    service.CallerIdValue = new CallerId();
    service.CallerIdValue.CallerGuid = user.UserId;

    // Create a SendEmail request.
    SendEmailRequest req = new SendEmailRequest();
    req.EmailId = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC");
    req.TrackingToken = "";
    req.IssueSend = true;

    // Send the email message.
    SendEmailResponse res = (SendEmailResponse)service.Execute(req);
    Friday, August 14, 2009 2:16 PM
  • Hi.

    There are no way to fill custom field. But you can use following algorithm:

    email mail = new email();
    //fields filling
    Guid id = crmservice.Create(mail);

    DynamicEntity dmail = new DynamicEntity("email");
    dmail["new_customfield"] = blah;
    crmservice.Update(dmail);

    but here you have two server calls...
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Friday, August 14, 2009 2:17 PM
    Moderator
  • how do i get the id of the email i just created?

    whats after service.create(email)

    Friday, August 14, 2009 3:24 PM
  • Hi.

    I beg a pardon.

    Correct code is following:

    email mail = new email();
    //fields filling
    Guid id = crmservice.Create(mail);

    DynamicEntity dmail = new DynamicEntity("email");
    dmail["emailid"] = new Key(id);
    dmail["new_customfield"] = blah;
    crmservice.Update(dmail);
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    • Marked as answer by T Bonz Friday, August 14, 2009 4:05 PM
    Friday, August 14, 2009 3:54 PM
    Moderator