About Me

My photo
a Dynamic and Energetic guy.....

Saturday, October 22, 2011

Get SharePoint Webapplication port number in 2010

1. Open a text document
2. Type the following lines

"echo Getting all SharePoint ports
pushd C:\Windows\System32\inetsrv
appcmd list wp
cd C:\Windows\System32\inetsrv
pause"


3. save as "myApps.cmd"
4. Run as Administrator

Friday, October 21, 2011

SharePoint 2010 close the popup and redirect parent

In SharePoint 2010 we have popup windows in many places.

If we need to close the PopUp and redirect the parent to a new page or reload the PopUp we can use simple code :)

Server side Code In the POPUP page
string redirectUrl = ResourceWrapper.GetAAFResource("PopupMyApprovalsLink");
Response.Write("script type='text/javascript'>window.frameElement.navigateParent('"+ redirectUrl +"'));
also we can use,
Response.Write("script type='text/javascript'>window.frameElement.commitPopup()");
to close the PopUp

Thursday, October 6, 2011

Excel Macro To Send Emails Automatically

Option Explicit

Private Sub Worksheet_Calculate()
    Dim FormulaRange As Range
    Dim NotSentMsg As String
    Dim MyMsg As String
    Dim SentMsg As String
    Dim MyLimit As Date

    NotSentMsg = "Not Sent"
    SentMsg = "Sent"

    'Above the MyLimit value it will run the macro
    MyLimit = Date   //Set The Current Date

    'Set the range with Formulas that you want to check
    Set FormulaRange = Me.Range("J6:J60") //Date Range

    On Error GoTo EndMacro:
    For Each FormulaCell In FormulaRange.Cells
        With FormulaCell
            If IsDate(.Value) = False Then
                MyMsg = "Not a date"
            Else
                If .Value < MyLimit Then
                    MyMsg = SentMsg
                    If .Offset(0, 1).Value = NotSentMsg Then
                        Call Mail_with_outlook2  //Call To Send Emails
                    End If
                Else
                    MyMsg = NotSentMsg
                End If
            End If
            Application.EnableEvents = False
            .Offset(0, 1).Value = MyMsg
            Application.EnableEvents = True
        End With
    Next FormulaCell

ExitMacro:
    Exit Sub

EndMacro:
    Application.EnableEvents = True

    MsgBox "Some Error occurred." _
         & vbLf & Err.Number _
         & vbLf & Err.Description

End Sub
=================================================
Email Sending Part
=================================================
Sub Mail_with_outlook2()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strto As String, strcc As String, strbcc As String
    Dim strsub As String, strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strto = Cells(FormulaCell.Row, "P").Value
    strcc = ""
    strbcc = ""
    strsub = "Do an update"
    strbody = "Hi " & Cells(FormulaCell.Row, "L").Value & vbNewLine & vbNewLine & _
              "Your expiry date is: " & Cells(FormulaCell.Row, "J").Value & vbNewLine & _
              "for the task of : " & Cells(FormulaCell.Row, "C").Value & _
              vbNewLine & vbNewLine & "Do an update" & _
              vbNewLine & vbNewLine & "Thanks." & _
              vbNewLine & vbNewLine & "Regards," & _
              vbNewLine & vbNewLine & "Marina Samaratunge"

    With OutMail
        .To = strto
        .CC = strcc
        .BCC = strbcc
        .Subject = strsub
        .Body = strbody
        'You can add a file to the mail like this
        '.Attachments.Add ("C:\test.txt")
        .Display    ' or use .Send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

My Masters