Utils Examples

Shortcuts:
Clarizen .Net wrapper: http://clarizen.caglar.com
Sample .Net project: Download samples.zip or browse/fork on GitHub

SendEmail

Here is how to send an email to an internal Clarizen user:

using System;
using Clarizen.API.V2_0;
using Clarizen.API.V2_0.Utils;

namespace ClarizenSamples.Utils
{
    class SendEmail
    {
        static SendEmail()
        {
            API ClarizenAPI = new API();
            if (!ClarizenAPI.Login("username", "password"))
                return;

            // Set up the email
            recipient[] recipients = new recipient[] { new recipient(recipient.CZRecipientType.To, "ekin@caglar.com", "/User/4dxj4hbs5pqvmp2utn4q3ggib3") };
            string subject = "Hello world";
            string body = "This is an email test from the API";
            string relatedEntityId = String.Empty;
            Clarizen.API.V2_0.Utils.Request.sendEMail.CZAccessType accessType = Clarizen.API.V2_0.Utils.Request.sendEMail.CZAccessType.Public;

            // Send the email
            sendEMail util = ClarizenAPI.SendEmail(recipients, subject, body, relatedEntityId, accessType);
            if (util.IsCalledSuccessfully)
                Console.WriteLine("Email sent successfully");
            else
                Console.WriteLine("Email could not be sent. Error: " + util.Error);

            if (ClarizenAPI.Logout())
                Console.WriteLine("Logout successful. {0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession);
        }
    }
}

To send en email to an external user, you can initialise the recipients variable without an EntityId - as follows:

recipient[] recipients = new recipient[] { new recipient(recipient.CZRecipientType.To, "ekin@woto.com", "") };

Comments