I am looking for a macro to add the zip folder from the file and add the into outlook mail.
before that I have to copy a specific range from a different workbook and have to paste it in the body of the email .then I want to add a zipped folder as an attachement. I tried with below code but it is not working. please help me
Sub Sending_Mails()
ActiveWorkbook.Sheets("Summary").Select
Set pt = ActiveSheet.PivotTables("Summary")
Range("A5").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Selection.Columns.AutoFit
Set rng = Nothing
On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeVisible)
Set rng = Sheets("sheet1").Range("A1:K14").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
trbody = "Dear Team," & "<br>" & "<br>" & _
"Please find the Summary based on the updated system data and the updated Manifest file.Attached is the Compare sheet for your review." & "<BR>" & "<BR>"
Signature = Chr(10) & Chr(10) & Chr(10) & "Thanks & Regards" & Chr(10) & Chr(10) & Chr(10) & "<BR>" & "<BR>" & "Balaji"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "balaji.suriyanarayanan@outlook.com"
.BCC = ""
.Subject = "Request For System Data"
.HTMLBody = strbody & RangetoHTML(rng) & Signature
.Attachments.Add = "C:\Users\Balaji\Desktop\Automation\comparesheet.zip"
.Send
End With
MsgBox ("Mail sent successfully"), vbOKOnly
Application.DisplayAlerts = False
ActiveWorkbook.Close
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
before that I have to copy a specific range from a different workbook and have to paste it in the body of the email .then I want to add a zipped folder as an attachement. I tried with below code but it is not working. please help me
Sub Sending_Mails()
ActiveWorkbook.Sheets("Summary").Select
Set pt = ActiveSheet.PivotTables("Summary")
Range("A5").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Selection.Columns.AutoFit
Set rng = Nothing
On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeVisible)
Set rng = Sheets("sheet1").Range("A1:K14").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
trbody = "Dear Team," & "<br>" & "<br>" & _
"Please find the Summary based on the updated system data and the updated Manifest file.Attached is the Compare sheet for your review." & "<BR>" & "<BR>"
Signature = Chr(10) & Chr(10) & Chr(10) & "Thanks & Regards" & Chr(10) & Chr(10) & Chr(10) & "<BR>" & "<BR>" & "Balaji"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "balaji.suriyanarayanan@outlook.com"
.BCC = ""
.Subject = "Request For System Data"
.HTMLBody = strbody & RangetoHTML(rng) & Signature
.Attachments.Add = "C:\Users\Balaji\Desktop\Automation\comparesheet.zip"
.Send
End With
MsgBox ("Mail sent successfully"), vbOKOnly
Application.DisplayAlerts = False
ActiveWorkbook.Close
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub