Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, July 30, 2015

How to trigger mail in ExactTarget using C# code



ExactTarget is a cloud service provided by Salesforce for running email campaign for email marketing. 

Here is a code to trigger emails in ExactTarget via its web service.


Change necessary values in below code and call the method. That’s it.

static void TriggerEmail()
{
    SoapClient client = new SoapClient();
    client.ClientCredentials.UserName.UserName = "xyz";
    client.ClientCredentials.UserName.Password = "xyzpassword";

    //Create a new subscriber - person email id
    Subscriber newSub = new Subscriber();
    newSub.EmailAddress = "abc@test.com";
    newSub.SubscriberKey = "abc@test.com";

    //Create the subscriber attributes
    newSub.Attributes = new ExactTargetClient.Attribute[4];

    //Attribute - First Name
    newSub.Attributes[0] = new ExactTargetClient.Attribute();
    newSub.Attributes[0].Name = "First Name";
    newSub.Attributes[0].Value = "Enter your first Name Here";

    //Attribute - Last Name
    newSub.Attributes[1] = new ExactTargetClient.Attribute();
    newSub.Attributes[1].Name = "Last Name";
    newSub.Attributes[1].Value = "Enter your Last Name Here";

    //Attribute - Zip Code
    newSub.Attributes[2] = new ExactTargetClient.Attribute();
    newSub.Attributes[2].Name = "Zip Code";
    newSub.Attributes[2].Value = "110011";

    //Attribute - State
    newSub.Attributes[3] = new ExactTargetClient.Attribute();
    newSub.Attributes[3].Name = "State";
    newSub.Attributes[3].Value = "Johannesburg";

    //Create a TriggerSend that uses an existing TriggerSendDefinition
    TriggeredSend ts = new TriggeredSend();
    ts.TriggeredSendDefinition = new TriggeredSendDefinition();

    //The external key assigned to the TriggerSendDeinition at ExactTarget
    ts.TriggeredSendDefinition.CustomerKey = "101"; //Keep in config file
    ClientID clientID = new ClientID();
    clientID.ID = 1234567; //Keep in config file
    ts.Client = clientID;

    //Instantiate the CreateOptions object for the create call
    CreateOptions cOptionsTS = new CreateOptions();
    cOptionsTS.RequestType = RequestType.Asynchronous;
    cOptionsTS.RequestTypeSpecified = true;

    ts.Subscribers = new Subscriber[] { newSub };

    try
    {
        //Create the TriggeredSend
        string tsRequestID = "";
        string tsStatus = "";
        CreateResult[] tsResults = client.Create(cOptionsTS, new APIObject[] { ts }, out tsRequestID, out tsStatus);
        TriggeredSendCreateResult tsCreateResults = tsResults[0] as TriggeredSendCreateResult;

        Console.WriteLine("Status Code: " + tsResults[0].StatusCode);
        Console.WriteLine("Status Message: " + tsResults[0].StatusMessage);
        Console.ReadLine();

        //Check for Error
        if (tsStatus != "OK") { throw new Exception(); }

    }
    catch (Exception exCreate)
    {
        Console.WriteLine(exCreate.Message);
        Console.ReadLine();
    }
}

Please leave your comments or share this code if it’s useful for you.

Tuesday, July 28, 2015

Luke for Sitecore Lucene search



Today I learn about Luke diagnostic tool which is used for analyzing Lucene index files.

This is developed in Java. So you need JVM in m





achine. You can download it from https://code.google.com/p/luke/
I installed lukeall-3.5.0.jar file      

             

After installation, browse you index folder path as highlighted in yellow color in below image


From this tool you can check which fields are indexing by Lucene.


You can search content items which are indexed based on particular template as shown in below image like 

_template:e5378d89080c4137898ec400b7dc4d39

Here two things to remember
1.    Enter template ID in lower letters
2.    remove dash - from template id


Simple but very useful tool.

Please leave your comments or share this tip if it’s useful for you.