Hi All,

I am using the following code to send an email thru outlook, its working fine when I am using Microsoft Office 2003, but in MS Office 2007 this code is returning a run time error 438 while calling objOutlook.FnSendMailSafe.

 
Public Function FnSafeSendEmail(strTo As String, _
                    strSubject As String, _
                    strMessageBody As String, _
                    Optional strAttachmentPaths As String, _
                    Optional strCC As String, _
                    Optional strBCC As String) As Boolean

    Dim objOutlook As Object ' Note: Must be late-binding.
    Dim objNameSpace As Object
    Dim objExplorer As Object
    Dim blnSuccessful As Boolean
    Dim blnNewInstance As Boolean
     On Error Resume Next
    Set objOutlook = GetObject("", "Outlook.Application")
    On Error GoTo 0
    If objOutlook Is Nothing Then
         Set objOutlook = CreateObject("Outlook.Application")
        blnNewInstance = True
        Set objNameSpace = objOutlook.GetNamespace("MAPI")
        Set objExplorer = objOutlook.Explorers.Add(objNameSpace.Folders(1), 0)
        objExplorer.CommandBars.FindControl(, 1695).Execute
        objExplorer.Close
        Set objNameSpace = Nothing
        Set objExplorer = Nothing
    End If
    strCC = Module1.strCC
    blnSuccessful = objOutlook.FnSendMailSafe(CStr(strTo), CStr(strCC), CStr(strBCC), _
                                                CStr(strSubject), CStr(strMessageBody), _
                                                CStr(strAttachmentPaths))
    If blnNewInstance = True Then objOutlook.Quit
    Set objOutlook = Nothing
    FnSafeSendEmail = blnSuccessful
End Function
Please help...

Thanks