Private Sub Send_mail_Click()
'On Error Resume Next
Dim Outlook As Outlook.Application
Dim Zprava As Object
Dim PDF_path As String
'PDF_path = ActiveWorkbook.Path & "\logfile.txt" '"\Objednávka.pdf"
PDF_path = "C:\EXCEL\logfile.txt" '"\Objednávka.pdf"
'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDF_path _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Set Outlook = New Outlook.Application
Set Zprava = Outlook.CreateItem(olMailItem)
Set myAttachments = Zprava.Attachments
On Error GoTo ERR1
myAttachments.Add PDF_path, olByValue, 1, ""
With Zprava
.To = Range("b1") 'adresát
.Subject = Range("b2") 'předmět
.Body = Range("b3") 'obsah
.CC = Range("b4") 'kopie mailu
.BodyFormat = olFormatPlain 'format mailu
.Display 'zobrazit okno
.Send 'odeslat
End With
GoTo konec
ERR1:
MsgBox "e-mai nebyl odeslán, něco je špatně"
MsgBox PDF_path
konec:
End Sub
Příloha: 48802_logfile.txt (1kB, staženo 20x) citovat