有没有办法在 VBA Outlook 电子邮件的主题行中编码,以对应从不同单元格中提取的多个部分?
Is there a way to code in VBA the subject line of an outlook email to correspond to multiple parts being pulled from different cells?
基本上希望编码适用于电子邮件主题行的这种格式:
组名 - 办公室 - 销售代表 - 截止日期
C3 - C4 - C5 - C6 - C7
所以输入到上述单元格中的信息都显示在主题行中。我目前只是将其编码为在弹出电子邮件后进行更改:
.主题="Group Name-Office-Rep-Lives-MM/DD/YY: Life&Disability Proposal Notification"
这可能吗?如果是这样,请帮助。谢谢!
这是我想出的。这取决于您的范围是否恒定,这会稍微改变您的代码。
Dim objNewWorkbook As Excel.Workbook
Dim objNewWorksheet As Excel.Worksheet
Dim objOutlookApp As Object
Dim objMail As Object
Dim group As String
Dim office As String
Dim salesrep As String
Dim mydate As String
mydate = Format(Date, "mm/dd/yy")
group = Range("c3")
office = Range("c4")
salesrep = Range("c5")
On Error Resume Next
Set objOutlookApp = CreateObject("Outlook.Application")
Set objMail = objOutlookApp.CreateItem(olMailItem)
'Set Email
With objMail
'.To = "Test"
.To = "Test"
.CC = ""
.Subject = "" & group & " " & office & " " & salesrep & " " & mydate & ""
.body = "Good Morning. " & vbCrLf & vbCrLf & ""
'.Attachments.Add ActiveWorkbook.FullName
.display
End With
基本上希望编码适用于电子邮件主题行的这种格式:
组名 - 办公室 - 销售代表 - 截止日期
C3 - C4 - C5 - C6 - C7
所以输入到上述单元格中的信息都显示在主题行中。我目前只是将其编码为在弹出电子邮件后进行更改:
.主题="Group Name-Office-Rep-Lives-MM/DD/YY: Life&Disability Proposal Notification"
这可能吗?如果是这样,请帮助。谢谢!
这是我想出的。这取决于您的范围是否恒定,这会稍微改变您的代码。
Dim objNewWorkbook As Excel.Workbook
Dim objNewWorksheet As Excel.Worksheet
Dim objOutlookApp As Object
Dim objMail As Object
Dim group As String
Dim office As String
Dim salesrep As String
Dim mydate As String
mydate = Format(Date, "mm/dd/yy")
group = Range("c3")
office = Range("c4")
salesrep = Range("c5")
On Error Resume Next
Set objOutlookApp = CreateObject("Outlook.Application")
Set objMail = objOutlookApp.CreateItem(olMailItem)
'Set Email
With objMail
'.To = "Test"
.To = "Test"
.CC = ""
.Subject = "" & group & " " & office & " " & salesrep & " " & mydate & ""
.body = "Good Morning. " & vbCrLf & vbCrLf & ""
'.Attachments.Add ActiveWorkbook.FullName
.display
End With