level 1
Sub SendEmailWithAttachment()
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim AttachmentPath As String
On Error GoTo ErrorHandler
Set OutlookApp = CreateObject("Outlook.Application")
With OutlookMail
.To = "[email protected]"
.Subject = "hi"
.Body = "t"
.Attachments.Add "C:\Users\wangshuyuan\Desktop\load\t.txt"
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Exit Sub
ErrorHandler:
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
2024年12月23日 02点12分
1
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim AttachmentPath As String
On Error GoTo ErrorHandler
Set OutlookApp = CreateObject("Outlook.Application")
With OutlookMail
.To = "[email protected]"
.Subject = "hi"
.Body = "t"
.Attachments.Add "C:\Users\wangshuyuan\Desktop\load\t.txt"
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Exit Sub
ErrorHandler:
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub