在确定如何提示选择我要通过电子邮件发送的文件时遇到问题。
Dim olApp As Outlook.Application
Dim diaFolder As FileDialog
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = "email@email.com"
olMail.Subject = "Subject Line"
olMail.Body = "Body of the Email"
diaFolder.AllowMultiSelect = True
diaFolder.Show
MsgBox diaFolder.SelectedItems
Set diaFolder = Nothing
olMail.Send
答案 0 :(得分:1)
您可以尝试一下:
Sub sendAttachment()
Dim olApp As Outlook.Application
Dim diaFolder As FileDialog
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
Dim lngCount As Long
olMail.To = "email@email.com"
olMail.Subject = "Subject Line"
olMail.Body = "Body of the Email"
' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show
' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
attFilePath = Application.FileDialog(msoFileDialogOpen).SelectedItems(lngCount)
olMail.Attachments.Add (attFilePath)
Next lngCount
End With
olMail.Display
'olMail.Send
End Sub
我希望这会对您有所帮助。