Here is the code to send and email with attachment from excel using outlook, I would like to send the email with Thunderbird and cannot work it out.
Sub EmailAspdf()
D… (了解更多)
Here is the code to send and email with attachment from excel using outlook, I would like to send the email with Thunderbird and cannot work it out.
Sub EmailAspdf()
Dim EApp As Object
Set EApp = CreateObject("outlook.application")
Dim EItem As Object
path = "C:\Users\nigel\OneDrive\Self Employed\invoices\"
invno = Range("C3")
custname = Range("B10")
fname = invno & " - " & custname
amt = Range("H41")
dt_issue = Range("C5")
term = Range("C6")
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
IgnorePrintAreas:=False, _
Filename:=path & fname
Set nextrec = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)
nextrec = invno
nextrec.Offset(0, 1) = custname
nextrec.Offset(0, 2) = amt
nextrec.Offset(0, 3) = dt_issue
nextrec.Offset(0, 4) = dt_issue + term
nextrec.Offset(0, 8) = Now
Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 6), Address:=path & fname & ".pdf"
Set EItem = EApp.CreateItem(0)
With EItem
.To = Range("B16")
.Subject = "Invoice PO No: " & Range("C4")
.Body = "Hi," & vbCrLf & "Please find invoice attached." & vbCrLf & "Regards" & vbCrLf & "Nigel"
.Attachments.Add (path & fname & ".pdf")
.Display
End With
Exit Sub