Thursday, May 28, 2015

Sending Emails with Image signature in Outlook


Dim outlukApp As Outlook.Application, outlukMailItm As Outlook.MailItem, emailid, myval, i As Integer, fullbody As String
Dim sigstring As String, signature As String
Sub sendMail()
    Set outlukApp = New Outlook.Application
    Set outlukMailItm = outlukApp.CreateItem(olMailItem)
    myval = Application.InputBox("Enter Mutiple  EmailId with ; delimiter", "EmailId")
    On Error Resume Next
    If myval = False Then
        Exit Sub
    Else
         emailid = Split(myval, ";")
        
       
         For i = 0 To UBound(emailid)
          fullbody = "Dear," & "<br>"
          fullbody = fullbody & "<p>Please find the attachment of new joinee details</p><br><br>"
          fullbody = fullbody & "<br> Best Regards,"
             With outlukMailItm
                     .Display
                     .To = emailid(i)
                    
                     .Subject = "New Joinee Details"
                     .HTMLBody = "Dear,<br>" & "<p>Please find the attachment of new joinee details</p><br><br><br> Best Regards," & .HTMLBody
                     .Attachments.Add (ThisWorkbook.Path & "\" & ThisWorkbook.Name)
                     .Display
                     Application.DisplayAlerts = False
                     .Send
             End With
            
            
         Next
     End If
    Set outlukMailItm = Nothing
    Set outlukApp = Nothing
   
End Sub

Saturday, May 23, 2015

Copy filtered Data with Criteria

Dim rowcount As Long, myrng As Range, cell
Sub copyFilteredData()
rowcount = ThisWorkbook.Sheets(1).Cells(Rows.Count, 2).End(xlUp).Row
Set myrng = ThisWorkbook.Sheets(1).Range("B2:B" & rowcount)
For Each cell In myrng
        If cell.Value Like "*LF*" Then
            cell.Offset(0, 1) = 0
        Else
            cell.Offset(0, 1) = 1
        End If
Next
ThisWorkbook.Sheets(1).Range("A1:B" & rowcount).AutoFilter field:=2, Criteria1:="*LF*"
ThisWorkbook.Sheets(1).Range("A1:B" & rowcount).SpecialCells(xlCellTypeVisible).Copy
ThisWorkbook.Sheets("Lost").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
ThisWorkbook.Sheets(1).ShowAllData
ThisWorkbook.Sheets(1).Range("A1:B" & rowcount).AutoFilter field:=2, Criteria1:="<>*LF*"
ThisWorkbook.Sheets(1).Range("A1:B" & rowcount).SpecialCells(xlCellTypeVisible).Copy
ThisWorkbook.Sheets("State").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll

End Sub

Download file