我不熟悉编码,一直在尝试将桌面上的单个文件附加到当前宏所创建的单个电子邮件中。文件名保存在活动WB中的工作表中,该工作表中包含我的收件人的名称和电子邮件。我想将文件名与适当的收件人匹配,并将文件附加到该收件人的电子邮件中。
任何帮助或建议将不胜感激。
我尝试添加一些我在网上找到的解决方案,但仍然无法解决。
Sub SendEmailfromOutlook()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim Path As String
Set OutApp = CreateObject("Outlook.Application")
For Each cell In Range("B2:B123")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = "Datalocker User Check"
.Body = "Hello " & Cells(cell.Row, "A").Value & "," _
& vbNewLine & "** Requires Response **" & vbCr & vbCr & _
"If you have received this email it is because we are doing a user check on datalocker secure file transfer." & vbCr & _
"Attached you will see a spreadsheet that shows all active users currently at your organisation." & vbCr & vbCr & _
"Normally we would request a form in order to make amendments but in this instance and for every new school term we will make all amendments that you need if you respond to this email" & vbCr & _
"I have attached a file for reference to roles and the functions they have." & vbCr & _
"Any new user that needs adding please fill their details in at the bottom of the table and we will add them as soon as we can." & vbCr & vbCr & _
"Can you also answer the following questions, these are being asked so we can update our records of these two roles in your school since there has been changes to staff in these roles that we haven't updated." & vbCr & vbCr & _
"Who is the current Headteacher and what is their email?" & vbCr & vbCr & _
"Who is the current Business/Office Manager and what is their email" & vbCr & vbCr & _
"Kind Regards" & vbCr & vbCr & _
"" & vbCr & _
"" & vbCr & _
"" & vbCr & _
"" & vbCr & _
""
.Save
End With
Next cell
End Sub