gpt4 book ai didi

excel - 如何识别带有#(哈希)的主题行?

转载 作者:行者123 更新时间:2023-12-04 21:27:15 25 4
gpt4 key购买 nike

我有代码可以输入在 Lotus Notes 中收到的电子邮件的主题和电子邮件地址。

Forward_Email "Subject text*", "email1@address.com"
然后代码在我的收件箱中查找 Subject text ,如果找到匹配项,它将将该电子邮件转发到指定的电子邮件地址。
当主题行包含字符 # 时(哈希)代码在收件箱中找不到该主题行并删除 vbCrLf & findSubjectLike & vbCrLf & "not found in Inbox" MsgBox 作为响应。
如何让它识别带有 # 的主题行(哈希)?
Public Sub Forward_Email(findSubjectLike As String, forwardToEmailAddresses As String)
Dim NSession As Object
Dim NMailDb As Object
Dim NViewObj As Variant
Dim NInboxView As Object
Dim NDocument As Object
Dim NUIWorkspace As Object
Dim NUIDocument As Object
Dim NFwdUIDocument As Object

Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.CurrentDatabase

For Each NViewObj In NMailDb.Views
If NViewObj.IsFolder And NViewObj.Name = "($Inbox)" Then
Set NInboxView = NViewObj
Exit For
End If
Next

Set NDocument = Find_Document(NInboxView, findSubjectLike)

If Not NDocument Is Nothing Then
Set NUIDocument = NUIWorkspace.EditDocument(False, NDocument)
NUIDocument.Forward

Set NFwdUIDocument = NUIWorkspace.CurrentDocument
NFwdUIDocument.GoToField "To"
NFwdUIDocument.InsertText forwardToEmailAddresses
NFwdUIDocument.GoToField "Body"
NFwdUIDocument.InsertText "This email was forwarded at " & Now
NFwdUIDocument.InsertText vbLf

NFwdUIDocument.Send
NFwdUIDocument.Close

Do
Set NUIDocument = NUIWorkspace.CurrentDocument
Sleep 100
DoEvents
Loop While NUIDocument Is Nothing
NUIDocument.Close
Else
MsgBox vbCrLf & findSubjectLike & vbCrLf & "not found in Inbox"
End If

Set NUIDocument = Nothing
Set NFwdUIDocument = Nothing
Set NDocument = Nothing
Set NMailDb = Nothing
Set NUIWorkspace = Nothing
Set NSession = Nothing
End Sub
Private Function Find_Document(NView As Object, findSubjectLike As String) As Object

Dim NThisDoc As Object
Dim thisSubject As String

Set Find_Document = Nothing

Set NThisDoc = NView.GetFirstDocument
While Not NThisDoc Is Nothing And Find_Document Is Nothing
thisSubject = NThisDoc.GetItemValue("Subject")(0)
If LCase(thisSubject) Like LCase(findSubjectLike) Then Set Find_Document = NThisDoc
Set NThisDoc = NView.GetNextDocument(NThisDoc)
Wend

End Function

最佳答案

问题是

If LCase(thisSubject) Like LCase(findSubjectLike) Then
Like Operator接受模式匹配和 #是一个通配符,代表任何单个数字 (0-9)。
所以在 If "#Subject text" Like "#Subject text" Then它查找数字而不是 # .所以你需要更换 #通过 [#]findSubjectLike所以它匹配 [charlist] charlist 中的任何单个字符。
LCase(Replace$(findSubjectLike, "#", "[#]"))
请注意,您可能还会遇到 ? 的问题。和 *以及 []主题中的字符,因为它们是 Like 中的特殊字符运算符(operator)。
如果您没有使用 Like 的模式匹配运算符(operator) …
… 并尝试查找 准确 匹配然后你可以切换表单 Like=
If LCase(thisSubject) = LCase(findSubjectLike) Then
… 并尝试找出 findSubjectLikethisSubject 的一部分那么您可以使用 InStr function
If InStr(thisSubject, findSubjectLike) > 0 Then

关于excel - 如何识别带有#(哈希)的主题行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69128761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com