Le Café Central de
Deva             


                    ... Deva blogs!!



  • Le Café Central de DeVa

    .Net Troubleshooting : How to uninstall the components of the .NET Framework 3.5 SP1?

    • 1 Comments

    Do you want to un-install the components of the .Net Framework 3.5 SP1?

    Then you need to read this article (article by Aaron),  in which he described his experience, how to uninstall the components of the .Net Framework 3.5 SP1?

    He gave the clear step-by-step information how we can uninstall the components of the .Net framework 3.5 SP1 in Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008.

    Related article:

    Download Microsoft Framework 3.5
    http://www.microsoft.com/downloads/details.aspx?FamilyId=333325FD-AE52-4E35-B531-508D977D32A6&displaylang=en

  • Le Café Central de DeVa

    Troubleshooting : EWS request throws “The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel” ?

    • 2 Comments

    One of my customer updated that whenever they try to make the remote Exchange Web Service (EWS) call from his C#.Net 2008 application (VS.Net 2008 - .Net Framework 3.x), he gets the following error:

    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

    I had a detailed look at their application code.

    // Create the Exchange Service Binding        
    ExchangeServiceBinding esb = new ExchangeServiceBinding();        
     
    // Add its relevant Credentials like user name, password, domain and URL        
    esb.Credentials = new NetworkCredential(userName, Password, domain);        
    esb.Url = @"https://myexchangeserver/EWS/Exchange.asmx";

    We checked the credentials passed; it seems everything was fine. But still it was failing whenever we make the request to the server with the above same message. When we checked their environment, we found customer uses the self-signed certificate on the server. This is because, by default, .NET checks whether SSL certificates are signed by a certificate from the Trusted Root Certificate store.

    To over-ride this behavior, we need to use the following line in the code, which validate the x509 certificate:

    ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

    This will accept all certificates, regardless of why they are invalid, which resolved the customer’s issue.

    By validating the X509 certificate provided by the computer running Microsoft Exchange Server 2007 for SSL over HTTP, you help to provide a layer of security for the client application. You must validate certificates before you can start programming with Exchange Web Services proxy classes. If the callback is not set up, the first call will fail with a certificate error.

    Happy troubleshooting!!

  • Le Café Central de DeVa

    Part # 2 - Using C#.Net & Exchange Web Service (EWS) : How to create and send e-mail messages?

    • 6 Comments

    In this we will see how to create & send e-mail messages using Exchange Web Service (EWS). It’s pretty simple with EWS to do.

           // Create the Exchange Service Binding
            ExchangeServiceBinding esb = new ExchangeServiceBinding();
     
           // Add its relevant Credentials like user name, password, domain and URL
            esb.Credentials = new NetworkCredential(userName, Password, domain);
            esb.Url = @"https://myexchangeserver/EWS/Exchange.asmx";
     
            // CreateItemType and set its relevant properties/values
            CreateItemType request = new CreateItemType();
           
            // Select Message Disposition specified
            request.MessageDisposition = MessageDispositionType.SendOnly;
            request.MessageDispositionSpecified = true;
          
           // Create MessageType and set its relevant properties/values
            MessageType message = new MessageType();
     
            // Enter value for subject
            message.Subject = subject;
            message.Body = new BodyType();
            message.Body.BodyType1 = BodyTypeType.Text;
     
           // Enter value for body
            message.Body.Value = body;
            message.ToRecipients = new EmailAddressType[1];
            message.ToRecipients[0] = new EmailAddressType();
           
           // Enter ToEmailAddress
            message.ToRecipients[0].EmailAddress = toEmailAddress;
     
           // Select Routing Type
            message.ToRecipients[0].RoutingType = "SMTP";
            request.Items = new NonEmptyArrayOfAllItemsType();
            request.Items.Items = new ItemType[1];
            request.Items.Items[0] = message;
            try
            {
               CreateItemResponseType response = esb.CreateItem(request);
     
               // Determine whether the request was a success.
                if (response.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
                {
                    throw new Exception(response.ResponseMessages.Items[0].MessageText);
                }
                else
                {
                    Console.WriteLine("Item was created");
                    Console.Read(); 
                }
              }
     
              catch(Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.Read();
                }

    Try this code snippet. Happy programming!!

  • Le Café Central de DeVa

    Code snippet using OOM : How to modify in-appropriate CSS/HTML tags available in the Outlook e-mail’s HTMLBody ?

    • 1 Comments

    Hi,

    Please find the following code snippet shows how we can modify/edit/add more or in-appropriate CSS/HTML tags available in the Outlook e-mail’s HTMLBody using Outlook Object Model:

    '[Code Snippet - Outlook Object Model 
    '[How to modify Outlook e-mail's inappropriate CSS/HTML tags from its HTML Body
    ...
    'Definition
    Dim str As String
    Dim str1 As String
    Dim omailitem As Outlook.MailItem
    Dim oattach As Outlook.Attachment
    Dim ofolder As Outlook.Folder
     
    'str1 stands for CSS/HTML tag that needs to be removed from mail's HTMLBody
    str1 = "<myNameisRemote_style_0 <!--.Quote{margin-left:1pt;padding-left:4pt;border-left:#6000002pxsolid;}--=""""" & "></style>"
    'Pick the Folder
    Set ofolder = Application.Session.PickFolder
    'Loop through the items
    For Each Item In ofolder.Items
    'Select a single item
    Set omailitem = Item
    str = Trim(omailitem.HTMLBody)
    'Check the HTMLBody has "myNameisRemote_style_0" string in this mail using Instr()
    If InStr(str, "myNameisRemote_style_0") Then
    'If Yes, then replace it
    str = Replace(str, str1, " ")
    Debug.Print "this has " & str
    ' Assign the replaced value back to HTMLBody
    omailitem.HTMLBody = str
    'Save the mail message
    omailitem.Save
    Else
    Debug.Print "Not Problem with <myNameisRemote_style_0 CSS_HTML tags"
    End If
    Next
    ....
  • Le Café Central de DeVa

    More resources for Exchange Server 2010 Beta

    • 1 Comments

    Feature: Exchange Management Shell in Exchange 2010

    When we start working with Exchange Server 2010, we have an enhanced Exchange Management Shell, which means more powerful one. As we know the Exchange Management Shell is a powerful command-line management interface; now we can administer every part of Exchange Server 2010, which is built on Windows PowerShell v2. With this you can be an administrator who needs to perform day-to-day management of your mailboxes, or you can be a developer who needs to automate administration using a custom line of business application. Either way, the Shell enables you to do more, faster.

    For more information, please read the following TechNet article written by David Strome.

    Additional resources:

Page 1 of 1 (5 items)