Lm th? no ? thm m?t s? t? b? cho th SMTP trong Visual Basic

D?ch tiu ? D?ch tiu ?
ID c?a bi: 317327 - Xem s?n ph?m m bi ny p d?ng vo.
? m?t Microsoft Visual Basic script Edition Phin b?n c?a bi vi?t ny, h?y xem 317680.
Bung t?t c? | Thu g?n t?t c?

? Trang ny


Bi t?ng b?c ny m t? cch s? d?ng m?t SMTP v?n chuy?n s? ki?n b?n r?a chn thm m?t s? t? b? cho i SMTP e-mail tin nh?n.

T?o s? ki?n sink

  1. T?o ra m?t m?i Microsoft Visual Basic ActiveX DLL. Tn cc d? n SMTPEventSink, v sau ?t tn m-un t? ch?i trch nhi?m.
  2. D?i D? n ti li?u tham kh?o, thm Microsoft CDO cho Exchange 2000 th vi?n, v sau thm Server m? r?ng ?i t?ng COM th vi?n.
  3. ?t o?n m? sau trong module:
    Dim TextDisclaimer As String
    Dim HTMLDisclaimer As String
    Implements IEventIsCacheable
    Implements CDO.ISMTPOnArrival
    Private Sub IEventIsCacheable_IsCacheable()
        'Just returns S_OK.
    End Sub
    Private Sub Class_Initialize()
      'TODO: Replace the sample disclaimer text with your own text.
      TextDisclaimer = vbCrLf & "DISCLAIMER:" & vbCrLf & "Sample Disclaimer Text."
      HTMLDisclaimer = "<p></p><p>DISCLAIMER:<br>Sample Disclaimer Text"
    End Sub
    Private Sub ISMTPOnArrival_OnArrival(ByVal Msg As CDO.IMessage, EventStatus As CDO.CdoEventStatus)
        If Msg.HTMLBody <> "" Then
            Dim szPartI As String
            Dim szPartII As String
            Dim pos As Integer
            'Search for the "</body>" tag and insert the disclaimer before that tag.
            pos = InStr(1, Msg.HTMLBody, "</body>", vbTextCompare)
            szPartI = Left(Msg.HTMLBody, pos - 1)
            szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) - (pos - 1))
            Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII
        End If
        If Msg.TextBody <> "" Then
            Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
        End If
        'Commit the content changes to the transport ADO Stream object.
        EventStatus = cdoRunNextSink
    End Sub
  4. Thay th? vn b?n t? ch?i trch nhi?m m?u b?ng vn b?n t? ch?i trch nhi?m ring c?a b?n, v sau xy d?ng DLL.

ng k? s? ki?n sink

? ng k? s? ki?n ch?m, s? d?ng cc t?p tin Smtpreg.vbs ?c ci ?t v?i b? pht tri?n ph?n m?m trao ?i (SDK).
  1. M?t d?u nh?c l?nh, xc ?nh v? tr cc \Exchange SDK\SDK\Support\CDO\Scripts th m?c, v sau g? nh sau: cscript smtpreg.vbs / thm 1 OnArrival SMTPDisclaimer SMTPEventSink.Disclaimer "th from=*@your-domain-here.com"

    N?u l?nh ny thnh cng, b?n nh?n ?c m?t thnh cng thng i?p ?c t?o b?i k?ch b?n.
  2. ? unregister s? ki?n ny, lo?i sau y: cscript smtpreg.vbs/remove 1 OnArrival SMTPDisclaimer
? bi?t thm chi ti?t v? vi?c qu?n l? s? ki?n bindings, truy c?p vo cc trang Web m?ng nh pht tri?n c?a Microsoft (MSDN) sau Trang web:

Ki?m tra s? ki?n sink

? ki?m tra s? ki?n ch?m, g?i th i?n t? cho m?t ng?i nh?n SMTP bn ngoi ? t? ch?c c?a b?n l ai. Ng?i nh?n s? nh?n ?c m?t s?a ?i thng bo v?i vn b?n t? ch?i trch nhi?m ?c b? sung vo cu?i tin nh?n.

Chu y N?u b?n s? d?ng m?t my khch MAPI, ch?ng h?n nh Microsoft Outlook, ? g?i cc th i?n t?, ng?i nh?n khng nh?n ?c m?t th i?n t? c?i. i?u ny l do th i?n t? ? n?p b?ng cch s? d?ng MAPI l khng trong m?t ?nh d?ng SMTP khi th i?n t? gy nn Theo t? ch?c s? ki?n SMTP v?n t?i. V? v?y, nh?ng thay ?i ?c th?c hi?n b?i cc m? c?a s? ki?n khng ri.


bit thm thng tin, bm vao s bai vit sau xem bai vit trong C s Kin thc Microsoft:
273233Khng th? thay ?i n?i dung th MAPI trong m?t s? ki?n CDO SMTP sink

Thu?c tnh

ID c?a bi: 317327 - L?n xem xt sau cng: 27 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Exchange Server 2003 Standard Edition
  • Microsoft Exchange Server 2003 Enterprise Edition
  • Microsoft Exchange 2000 Server Standard Edition
T? kha:
kbhowtomaster kbmt KB317327 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:317327

Cung cp Phan hi


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com