Contrast90
New Member
- Joined
- Oct 25, 2016
- Messages
- 4
Hi
Im having problems with sending the active worksheet by mail. The first part of the code works but the last part doesn't. My main problems are adding the email address and attaching the active worksheet. I have replaced the letters in the email with "x" in order to hide my email. I would really appreciate it with any advice.
Im having problems with sending the active worksheet by mail. The first part of the code works but the last part doesn't. My main problems are adding the email address and attaching the active worksheet. I have replaced the letters in the email with "x" in order to hide my email. I would really appreciate it with any advice.
Code:
Sub Mail()
'
' Mail Makro
'
Dim C As String
C = "Institution"
C = ActiveCell.Text
Dim Count As Integer
Sheets("data").Select
ActiveSheet.Range("$A$1:$X$43735").AutoFilter Field:=5, Criteria1:=C
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Users\xxxx\Desktop\Liste"
Range("A2").Select
ActiveSheet.Paste
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.to = "xxxx@xxx.xx.xx"
.CC = ""
.BCC = ""
.Subject = "!#" & " " & "C"
.Body = ""
.Attachments.Add (ActiveWorkbook.Liste.xlsx)
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub