5

ItemSendThisOutlookSession モジュールにコードを挿入して保存しました。一度は機能しましたが、機能しなくなりました。これは VBAproject.OTM として保存され、Outlook の再起動後にモジュールを開いたときにまだ存在しています。

Private Sub Application_ItemSend(ByVal Item As Object, _
                                 Cancel As Boolean)
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next

    ''# #### USER OPTIONS ####
    ''# address for Bcc -- must be SMTP address or resolvable
    ''# to a name in the address book
    strBcc = "someone@somewhere.dom"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                 "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If
    End If

    Set objRecip = Nothing
End Sub
4

3 に答える 3

3

アイテムの件名フィールドで and if ステートメントを使用する

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "exact match" Then

    strBcc = "someone@somewhere.dom"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                 "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If


    End If
    Item.Save

    Set objRecip = Nothing


End If

または、件名に単語を含む場合に使用します

If InStr(Item.Subject, "BCCSubject") = 0 Then


End If
于 2010-04-06T23:28:03.523 に答える
2

イベントをフックしているItemSend場合、それはクラスモジュールにWithEventsあり、通常のモジュールでそれを呼び出すためのコードである必要があります。また、Item.SaveBCCが固執するためのメッセージを実行する必要があります。

于 2010-03-26T16:27:37.227 に答える
0

私は最近この問題を抱えていました。.pst ファイルが何らかの方法で破損した後に開始され、scanpst.exe を実行する必要がありました (エラー メッセージではドライブの場所がわからないため、ドライブを検索する必要がありました)。

scanpst.exe を実行して問題が発生した後、これを修正しました。

まず、マクロ セキュリティをいじりました。最低設定にしました。マクロのセキュリティを変更する方法をカバーするリンクを次に示します。[ツール] > [マクロ] > [セキュリティ] に移動します。「マクロのセキュリティチェックなし」に設定しました。

次に、この正確なコードを使用しました:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next

' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
' to a name in the address book
strBcc = "PUT YOUR EMAIL ADDRESS HERE AND LEAVE THE QUOTES"

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If

Set objRecip = Nothing

End Sub

次に、保存ボタンをクリックしてから、小さな緑色の再生ボタンをクリックして、マクロを実行しました。マクロ名を聞かれました。私は bccUsername を使用し、作成をクリックしました。Modules編集者は、下にというセクションを追加しましたThisOutLookSession

その後、Outlook を再起動して 2 回テストしたところ、機能しました。

私が何をしたのか正確にはわかりませんが、これは手順にあまり関係していないので、同じ問題を抱えているあなたや他の人に役立つことを願っています.

于 2013-11-11T22:23:38.580 に答える