Anhang an die MAil
17.09.2016 11:57:58
Ralf
ich bräuchte mal Hilfe, nachfolgende Makro habe ich aus dem Netz mir zusammen gestellt.
Mein Problem ist es geht der Anhang nicht an der Mail mit raus.
Kann mir einer sagen wo das Problem liegt und warum, ich möchte ja auch was lernen.
Vielen Dank schon im Voraus für die Mühe
Gruß
Ralf
Sub PDFspeichern20()
ChDir "C:\Users\Büro 1\Desktop"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Büro 1\Desktop\Abrechnung." & Format(Now, "DD-MM-YY") & ".pdf", OpenAfterPublish:=True
send_email
End Sub
Public Function send_email()
Dim cdomsg As Object
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "XXXXXXXXX.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "XXXXXX"
.Update
End With
' build email parts
With cdomsg
.To = "XXXXXX"
.From = "XXXXXXXXX"
.Subject = "Abrechnung"
.TextBody = ""
myAttachments.Add "C:\Users\Büro 1\Desktop\Abrechnung." & Format(Now, "DD-MM-YY") & ".pdf"
.Send
End With
Set cdomsg = Nothing
End Function