[英]Change email subject depending on body text
We get email alerts from the system of one of our vendors with subjects "Alert for [SITENAME]
- Uplink status changed" and where the email body will contain one of following two texts strings:我们从我们的供应商之一的系统收到电子邮件警报,主题为“ [SITENAME]
警报 - 上行链路状态已更改”,并且电子邮件正文将包含以下两个文本字符串之一:
"the security appliance switched to using Internet 2 as its uplink." “安全设备切换到使用 Internet 2 作为其上行链路。”
or或
"the security appliance switched to using Internet 1 as its uplink." “安全设备切换到使用 Internet 1 作为其上行链路。”
We need to read each email to see if an uplink has gone up or down and I want this to be visible from the subject.我们需要阅读每封电子邮件以查看上行链路是否上升或下降,我希望从主题中可以看到这一点。
Sub changesubject()
Dim myMessage As Outlook.MailItem
Set myMessage = Outlook.ActiveInspector.CurrentItem
If myMessage.Body = "Internet 2 as its uplink" then
myMessage.Subject = myMessage.Subject & "- PRIMARY LINK DOWN"
End If
If myMessage.Body = "Internet 1 as its uplink" then
myMessage.Subject = myMessage.Subject & "- PRIMARY LINK UP"
End If
End Sub
Use Like
in your If
statements instead of =
.在If
语句中使用Like
而不是=
。 This explains how the Like
operator works. 这解释了Like
运算符的工作原理。 You can also Google "VBA Like" and you will get more results你也可以谷歌“VBA Like”,你会得到更多的结果
Sub changesubject()
Dim myMessage As Outlook.MailItem
Set myMessage = Outlook.ActiveInspector.CurrentItem
If myMessage.Body Like "*Internet 2 as its uplink*" then
myMessage.Subject = myMessage.Subject & "- PRIMARY LINK DOWN"
End If
If myMessage.Body Like "*Internet 1 as its uplink*" then
myMessage.Subject = myMessage.Subject & "- PRIMARY LINK UP"
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.