質問

??C#????????????????VB??????????????????????????????????????????

????????????kranichs?????????????????????????????????????????????????????????????????????????

?????????propercases

??VB???????????:

Imports System

Imports System.Collections.Generic

Imports System.Text

Imports Microsoft.Exchange.Data.Transport

Imports Microsoft.Exchange.Data.Transport.Routing

Imports Microsoft.Exchange.Data.Transport.Smtp


Namespace mySubjectAgent

    NotInheritable Class myRoutingFactory

        Inherits RoutingAgentFactory

        Public Overrides Function CreateAgent(ByVal server As SmtpServer) As RoutingAgent
            Return New MyAgent
        End Function

    End Class

    Public Class MyAgent
        Inherits RoutingAgent

        Private Sub MyEndOfDataHandler(ByVal source As SubmittedMessageEventSource, ByVal e As QueuedMessageEventArgs) Handles Me.OnSubmittedMessage
            If e.MailItem.Message.Subject.Length = 0 Then
                e.MailItem.Message.Subject = "Kranichs Jewelers"
            Else
                e.MailItem.Message.Subject = StrConv(e.MailItem.Message.Subject, VbStrConv.ProperCase)
            End If
        End Sub

    End Class

End Namespace

???????????.. ?????QUE??????????????????????Exchange????????????????????????????????

???????????????

役に立ちましたか?

解決

There's two things you can try to start out:

  1. Check Chris Haas' suggestion above and either add a try/catch to deal with nulls, or specifically watch for it using something like this:

    if e.mailitem isnot nothing andalso e.mailitem.message isnot nothing andalso e.mailitem.subject isnot nothing then
    ' Fix case
    elseif e.mailitem isnot nothing andalso e.mailitem.mesasge isnot nothing then
    ' Subject isn't set, go ahead and set one.
    end if

  2. Remove the code that does anything and just add some dummy code to replace it (like Dim i as integer = 2) to make sure that Exchange isn't stalling out just by having a transport agent of any kind.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top