[英]Populating email body through Lotus Notes - Excel VBA
I currently have a little code segment to pre-populate emails and attaching the current worksheet. 我目前有一些代码段可以预填充电子邮件并附加当前的工作表。 What I need to finalize is to also add a standard body, here is my code below; 我需要最后确定的是还要添加一个标准主体,这是下面的代码;
Sub SDFMail()
Dim name As Variant
Dim subj As Variant
name = InputBox("Please enter name of requestor")
subj = InputBox("Please enter the subject of the service ticket")
dias = InputBox("Please enter the date in the following format DD-MM-YYYY")
Dim strrecipient As String: strrecipient = "anthonnybelanger@gmail.com"
Dim strsubject As String: strsubject = subj & " - " & name & " - " & dias
Application.Dialogs(xlDialogSendMail).Show arg1:=strrecipient, arg2:=strsubject
End Sub
Thank you for your help, 谢谢您的帮助,
Best, 最好,
A 一种
You will not have much of options if you use dialogs. 如果使用对话框,则没有太多选择。 Use the code below so that you can control everything easily. 使用下面的代码,以便您可以轻松控制所有内容。
Copy and paste the code in a module and run it. 将代码复制并粘贴到模块中并运行它。 If this is what you needed, please hit the check mark next to this question ;) 如果这是您需要的,请点击此问题旁边的复选标记;)
Sub SDFMail()
Dim strSubject As String
Dim strRecipient As String
Dim name As String
Dim subj As String
Dim dias As String
Dim outlook As Object
Dim outlookMail As Object
'Define outlook object
Set outlook = CreateObject("Outlook.Application")
Set outlookMail = outlook.CreateItem(0)
'Get the info from the user
name = InputBox("Please enter name of requestor")
subj = InputBox("Please enter the subject of the service ticket")
dias = InputBox("Please enter the date in the following format DD-MM-YYYY")
'Format subject
strRecipient = "anthonnybelanger@gmail.com"
strSubject = subj & " - " & name & " - " & dias
'Save the workbook
ThisWorkbook.Save
'populate then New Email attributes
With outlookMail
.To = strRecipient
.CC = "SampleCC@email.com"
.BCC = "SampleBCC@email.com"
.Subject = strSubject
.Body = "This is a default body text."
.Attachments.Add ThisWorkbook.FullName
.Display
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.