Wednesday, December 6, 2017

Make meeting request within email Outlook


  1. Leave your email inside outlook. Dont pop out.
  2. Click Reply or Reply All
  3. Click Home button on menu bar
  4. In 3rd partition (Respond), click on Meeting which will turn that email into meeting email
HTH

Saturday, November 18, 2017

iPhone X taking too long to activate

Hello
If u like where u couldn’t your new awesome iPhone X activated in reasonable time, please go ahead use iTunes to activate it and you will be done in less than 2 mins.

HTH

Saturday, April 8, 2017

Update statement with case statement in SQL Server

It is very important to know that how case statement will behave when used in Update query.
As we know case statement can have multiple "when" and else is not required.
So if the query is executed where no condition is met defined in case statement then the row will be updated to null value. So to avoid this, you need else statement with whatever value you want to keep.

See example below:

'create table
CREATE TABLE #test (worktime DATETIME)

' insert current time
INSERT INTO #test( worktime ) VALUES  ( GETDATE());

' check value
SELECT * FROM #test

' now write case statement with no else and not meeting any condition
UPDATE #test
SET worktime = CASE WHEN worktime IS NULL THEN GETDATE() 
                                   WHEN worktime < '1/1/2010' THEN GETDATE()-7 
END

Check the value in table, the row will be updated to null.

So always mention else part of case statement when using case.

HTH,

Saturday, April 1, 2017

Use EWS (Exchange Web Services) to send emails

EWS (Exchange Web Services) is an API that you can use to interact with Exchange items such as mail, calendar, contacts etc.
You can also use Outlook Object model to send emails. 
To work with EWS, you have install EWS (it only works with 64 bit machine). The link to download is here

Here is the sample code to Send an email - 


' import namespace
Imports Microsoft.Exchange.WebServices.Data

Public Class TestMail

    Public Sub SendMailusingEWS()

        Dim service As ExchangeService = New ExchangeService(ExchangeVersion.Exchange2010_SP1)

        'Connect to Exchange Web Services as testaccount at mydomain.com.
        service.Credentials = New WebCredentials("testaccount", "password", "mydomain")

        'OR try this if above doesn't work. This credential depend how AD is configured. 
        'service.Credentials = New WebCredentials("testaccount@mydomain.com", "password")

        ' This is to bypass server certificate. ONLY FOR DEBUGGING. May not required.
        System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(sender, certificate, chain, sslPolicyErrors) True

        'Set the URL of the property of service.
        service.Url = New System.Uri("https://myexchange.mydomain.com/EWS/Exchange.asmx")

        'For exchange365
        'service.Url = New System.Uri("https://outlook.office365.com/EWS/Exchange.asmx")

        'OR you can also set the URL by calling autodiscoverURL. You might want to cash it and define as above.
        'service.AutodiscoverUrl("testaccount@mydomain.com")

        'Create msg object and set its connection by passing service object  
        Dim msg As EmailMessage = New EmailMessage(service)
        msg.Subject = "test from EWS service"
        msg.Body = "saqib is testing"
        msg.ToRecipients.Add("mymail@gmail.com")
        msg.SendAndSaveCopy()

    End Sub

End Class

Saturday, February 4, 2017

Pass an Variant Array from VB6 to VB.net

There is no variant type in vb.net.
If you have an Variant array declared in VB6 and you are trying to pass this to VB.net, you would need to pass variant as object .net and declare an array and loop thru each item from the passed object and add it to array.

Example:

My VB6 code:
 Dim variantArray As Variant
 variantArray = Empty  
 ReDim variantArray(1)
 variantArray(0) = "C:\pic1.jpg"
 variantArray(1) = "C:\pic2.jpg"

So now in VB.net, you can either pass this parameter to a function or a property of an object of .net class. See code below as property:
 Private _stringArray As String()  
 Public Property StringArray As Object
     Get  
         Return _stringArray  
     End Get  
     Set(value As Object)  
       If Not value Is Nothing Then  
           ReDim _stringArray(value.length - 1)  
           For i As Int16 = 0 To value.length - 1  
               _stringArray(i) = value(i)  
           Next  
       End If  
     End Set  
 End Property  

Monday, January 16, 2017

Return object from VB.net to VB6 (Object not defined)

Hi,

I was working on a project where there was a change needed in VB6 application.
This change was implemented in VB.net but there were few things involved in returning values from .net to VB6 which caused little challenge.
Without realizing, I thought that the class object I m creating in .net would be understood by VB6 but, I was wrong.

I was keep getting error when I was calling .net function in VB6 that was returning object in vb.net.
The error was "object not defined".

To fix this problem, what I did, I decomposed my single class into 2 classes; say ClassA and ClassB.
Then I created objects of each class in VB6 and then used properties to pass values from ClassA object to ClassB.

In the constructor of ClassA, I initialized the property which was ReadOnly property in my class.
Then I passed this property by assigning to ClassB object's property.

What I was doing wrong returning ClassB object from .net function to VB6 which wasn't working. So  I guess the correct way to create separate classes and objects and then pass values between them using properties.

HTH.