使用log4net在Exchange服务器上发送电子邮件

时间:2015-09-19 11:16:25

标签: c# .net email exchange-server log4net

您好我使用以下凭据在SMTP服务器上发送邮件

  <log4net>
    <!--
  This writes the log information to the console window.  It only logs events
  that are at least at the INFO level (which would mean that DEBUG events are not captured.
  -->
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newlineExtra Info: %property{testProperty}%newline%exception" />
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="DEBUG" />
        <levelMax value="FATAL" />
      </filter>
    </appender>
    <!--
  This stores information in the mylogfile.txt file.  It only captures log events
  that contain the key word test or error.
  -->
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="null" />
      <appendToFile value="true" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <datePattern value="yyyyMMdd" />
      <rollingStyle value="Date" />
      <maxSizeRollBackups value="50" />
      <maximumFileSize value="100MB" />
      <!--<staticLogFileName value="true"/>-->
      <!--<filter type="log4net.Filter.StringMatchFilter">
        <stringToMatch value="test"/>
      </filter>
      <filter type="log4net.Filter.StringMatchFilter">
        <stringToMatch value="error"/>
      </filter>
      <filter type="log4net.Filter.DenyAllFilter"/>-->
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%-5level | %date{yyyy-MM-dd HH:mm:ss.fff tt} |  %5rms | %-22.22c{1} | %-method | %message%newline%exception" />
      </layout>
    </appender>
    <appender name="LogSmtpAppender" type="log4net.Appender.SmtpAppender">
      <authentication value="Basic" />
      <to value="abc@xyz.com" />
      <from value="from@xyx.com" />
      <!--<smtpHost value="1.16.4.2" />-->
      <username value="abc@xyx.com" />
      <password value="pass@123" />
      <subject type="log4net.Util.PatternString" value="subject" />
      <port value="25" />
      <bufferSize value="0" />
      <lossy value="true" />
      <evaluator type="log4net.Core.LevelEvaluator">
        <threshold value="ERROR" />
      </evaluator>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%-5level | %date{yyyy-MM-dd HH:mm:ss.fff tt} | %5rms | %-22.22c{1} | %method | %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>

这在POP / IMAP服务器上运行良好。但现在我的电子邮件客户端在Microsoft Exchange上使用以下凭据

http://s23.postimg.org/vi8emm1q3/mail.jpg (交换邮件凭证的快照)

但它不适用于交换凭据。谁能告诉我这里缺少什么。

谢谢, Preeti

1 个答案:

答案 0 :(得分:0)

问题在于反病毒正在阻止该端口。我可能需要连接IT管理员窥视才能对其进行排序。一旦我禁用防病毒电子邮件工作。