PDF per Mail sende
25.11.2014 22:55:37
dani
Ich habe ein kleines Problem, bei dem meine bescheidenen VBA Kenntnisse nicht ausreichen.
Eine voll funktionsfähige Lösung mit einer xls Datei habe ich schon, doch ich möchte die Datei als PDF versenden.
Hier meine funzende VBA Version:
Sub EMail__Senden_Ohne_Outlook()
Dim iNachricht As Object, iKonfiguration As Object, Felder As Variant
Dim strMailAdress$, strKennwort$, strTmpFile$
strMailAdress = "xxxxxx@gmail.com" '"Deine E-Mail-Adresse"
strKennwort = "xxxxxxxxx" 'Passwort angeben
'Datei für Anlage erstellen
strTmpFile = ThisWorkbook.Path
If Right$(strTmpFile, 1) "\" Then strTmpFile = strTmpFile & "\"
ChDrive strTmpFile
ChDir strTmpFile
'File Name für Nachricht
strTmpFile = strTmpFile & "Mail_" & ThisWorkbook.Name
'evtl. löschen fals vorhanden
If Dir(strTmpFile, vbNormal) "" Then Kill strTmpFile
'eine kopie der Datei speichern
ThisWorkbook.SaveCopyAs strTmpFile
Set iNachricht = CreateObject("CDO.Message")
Set iKonfiguration = CreateObject("CDO.Configuration")
iKonfiguration.Load -1
Set Felder = iKonfiguration.Fields
With Felder
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = strMailAdress
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strKennwort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" ' _
Postausgangsserver
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'SMTP-Port
.Item("http://schemas.microsoft.com/cdo/configuration/smtpservertimeout") = 60 'Timeout
.Update
End With
With iNachricht
Set .Configuration = iKonfiguration
.To = "xxxxxx@Proviter.com" 'Empfänger
.CC = "" 'Zur Kenntnis
.BCC = "" '.BCC nicht sichtbare Empfänger
.Sender = strMailAdress 'Von
.Subject = "Betreff" 'Betreffzeile
.TextBody = "Deine Nachricht!" 'Nachricht
.AddAttachment strTmpFile 'Anlage
.Send
End With
'Datei wieder löschen
If Dir(strTmpFile, vbNormal) "" Then Kill strTmpFile
End Sub
Wie gesagt möchte ich jedoch die Datei als PDF versenden.
Was muss ich am Code wie ändern?
Danke schon mal für eure Hilfe
Gruess Dani