Tag Archives: SMTP Sink

Part 1 : Developer Roadmap – Development Technologies for Exchange Server 2010


This two part article is targeted for the developer audience, if you’re the developer who want to create a develop custom application for Exchange Server 2010 or already has custom application designed for previous versions of Exchange Server 2010.

Some Exchange programming technologies that are available in versions of Exchange earlier than Microsoft Exchange Server 2010 are obsolete and have been replaced with other technologies. Per MSDN article, the programming technologies and APIs stated below have either been removed from Exchange 2010 or earlier versions of Exchange, are no longer supported for use with the current version of Exchange, or are no longer the recommended API to use to access Exchange.

Recommendation: We recommend that you use Exchange PowerShell commands to administer Exchange configuration data.

Recommendation: We recommend that you migrate your applications that use CDOEX to Exchange Web Services.

Recommendation: We recommend that you migrate your applications that use CDOEXM to use Exchange PowerShell commands.

Recommendation: We recommend that you migrate your applications that use CDOWF to use Windows Workflow Foundation Services.

Recommendation: Notification-based applications that work with Exchange 2010 should use transport agents.

Recommendation: We recommend that you migrate any CDO 1.2.1 applications to use Exchange Web Services.

Recommendation: To ensure continued future compatibility, we recommend that you consider migrating your ICS applications to use Exchange Web Services notifications.

Recommendation: We recommend that you migrate applications that use ExOLEDB to use Exchange Web Services.

  • Exchange Rules DLL is part of the sample code that shipped with the Exchange 5.5 and Exchange 2000 SDKs.

Recommendation: We recommend that you migrate applications that use the Exchange Rules DLL to use either MAPI or Exchange Web Services notifications.

Recommendation: Where possible, we recommend that applications that use Exchange Store Event sinks be migrated to use either transport agents or Exchange Web Services notifications.

Recommendation: We recommend that you migrate backup and restore applications that use streaming backup to use the Windows Volume Shadow Copy Service (VSS).

Recommendation: We recommend that you migrate applications that use Exchange WebDAV to use the Exchange Web Services.

Recommendation: We recommend that you migrate applications that use Exchange WebDAV notifications to use Exchange Web Services notifications.

Recommendation: We recommend that you migrate applications that use Exchange Web Forms to use either Windows SharePoint Services, or Active Server Pages.

Recommendation: We recommend that you use Exchange PowerShell commands to administer Exchange configuration data.

Recommendation: We recommend that you migrate applications that used WMI to use the Exchange PowerShell commands.

Happy Programming!!

Monitoring event sink # 25 – Recipients modified mail (using event sink) sent from PICKUP folder and lands in the DROP folder ?


Recipients modified email messages (using event sink) sent from PICKUP folder and lands in the DROP folder ?

The Pickup folder processes outgoing messages that are created as text files and then copied to the Pickup folder. When Request for Comments (RFC) 822 messages that are correctly formatted are copied to the Pickup folder, the SMTP service initiates delivery. In this replay method, the X-Sender envelope field and the X-Receiver envelope field are written to the e-mail message when the SMTP service puts the e-mail message into the Drop folder.

Note
The SMTP service puts the e-mail message into the Drop folder for local delivery on a computer where Exchange is not installed.

In this scenario, the Pickup operation honors the envelope fields that are written to the e-mail message

In detail

This is because, we will have an default domain entry in the SMTP mail area of IIS. This is the process that handles all mail that comes into your SMTP system that is not otherwise specified. This mail would be delivered based on the settings you make in the properties area of that default setting. This includes the name of the server that the mail claims to be from.

In addition to this default entry, you can also create an Alias Domain for any other domains you might own. Each one can have its own name. So where your default might say mail is coming from Mydomain.com, you can set up alias domains for domain.com and minedomain.com. Once you have those aliases set up, each alias then sends its mail to the DROP folder associated with that alias. The mail will sit there in the DROP folder, waiting for further processing. It assumes that another system is going to poll that DROP folder and do something with the mail.

If you end up with mail messages in your DROP folder because you created an alias domain by accident, simply delete that alias and then stop and restart the mail server. Now drag all the messages from the DROP area back into the PICKUP area. They will process through the default queue, following your normal rules and get out to your recipients.

.

Test and troubleshooting tools for various Exchange technologies


I tried to compose the test and troubleshooting tools for various exchange technologies. This initial list upto Exchange Server 2003. 

 





































































Technology

 


Tools for test and troubleshooting tools


Active Directory Services Interfaces (ADSI)

 


All standard test and debugging tools, as well as other Microsoft and third-party test and debugging tools, can be used.

 


Collaboration Data Objects for Windows 2000 (CDOSYS)

 


No special debugging tools are needed to debug applications that use CDOSYS.

 


CDOSYS SMTP/NNTP Event Sinks

 


No special debugging tools are needed to debug applications that use CDOSYS. For particularly difficult protocol-interaction issues, a network monitoring utility may prove helpful, but is typically not required.

 


Collaboration Data Objects for Exchange 2000 Server (CDOEX)

 


No special debugging tools are needed to debug applications that use CDOEX.

 


Collaboration Data Objects for Exchange Management (CDOEXM)

 


No special debugging tools are needed to debug applications that use CDOEXM.

 


Collaboration Data Objects for Exchange Workflow (CDOWF)

 


No special debugging tools are needed to debug applications that use CDOWF. Custom applications might be created to analyze the process audit logs created during process execution. If you are using the Workflow Designer for Exchange 2000 Server, enable Just-In-Time (JIT) script debugging. JIT starts the Microsoft Script Debugger when the error occurs. The debugger starts on the server, so you need to have access to the server.

 


Exchange OLE DB Provider (ExOLEDB)

 


No special debugging tools are needed to debug applications that use ExOLEDB.

 


Exchange Store Event Sinks

 


No special debugging tools are needed to debug applications that use Exchange store event sinks.

 


Exchange Web Forms

 


No special debugging tools are needed to debug applications that use Exchange Web forms. Note, however, that because the forms execute on the computer running Microsoft Exchange Server 2003, debugging may require the developer have access to the Exchange server. Always use caution when allowing anyone direct access to the Exchange server.

 


HTTP/Web Distributed Authoring and Versioning (WebDAV)

 


No special debugging tools are required to debug applications that use WebDAV. For particularly difficult protocol-interaction issues, a network monitoring tool may prove helpful. The NETMON.EXE tool can be very useful in debugging WebDAV protocol interactions. Because WebDAV queries are sometimes sensitive to minor syntactical differences, a WebDAV query tool can also be helpful.

 


WebDAV Notifications

 


No special debugging tools are needed to debug applications that use WebDAV Notifications. For particularly difficult protocol-interaction issues, a network monitoring tool may prove helpful, but is typically not required.

 


Incremental Change Synchronization (ICS)

 


No special debugging tools are needed to debug applications that use ICS.

 


Lightweight Directory Access Protocol (LDAP)

 


No special debugging tools are needed to debug applications that use LDAP. For particularly difficult protocol-interaction issues, a network monitoring tool may prove helpful, but is typically not required.

 


Messaging Application Programming Interface (MAPI)

 


No special debugging tools are needed to debug applications that use MAPI.

 


Outlook Object Model (OOM)

 


No special debugging tools are needed to use OOM.

 


Outlook Web Access

 


No tools are available for debugging calls to Microsoft Outlook® Web Access, because the internal architecture is not available for debugging, and the URL calls required to access Outlook Web Access programmatically are not documented or supported.

 


Exchange Rules

 


No special debugging tools are needed to debug applications that use Exchange rules. Client-side rules require Outlook for proper testing.

 


SMTP Event Sinks

 


No special debugging tools are needed to debug applications that use SMTP event sinks. For particularly difficult protocol-interaction issues, a network monitoring tool may prove helpful, but is typically not required.

 


Windows Management Instrumentation providers for Exchange (WMI)

 


No special tools are required to debug applications that use WMI.

 


Exchange Backup & Restore API

 


No special tools are required to debug applications that use the Exchange Backup and Restore API.

 


Exchange writer for the Windows Volume Shadow Copy Service

 


No special tools are required to debug applications that use the Windows Volume Shadow Copy Service.

 

API’s that are not included in Exchange Server 2007 ?


When you migrated from Microsoft Exchange 2000 & 2003, where they provide several API’s that are not included in Microsoft Exchange Server 2007. Please find the following API’s that are not included in the Exchange Server 2007 environment & the recommended technologies to migrate to.


APIs that are not included in Exchange 2007
















































API


Status in Exchange 2007


Replacement Technology


CDOEX


De-emphasized but still supported.


Exchange Web Services


CDOEXM


Not included in Exchange 2007.


Microsoft Windows PowerShell and Exchange 2007 commands


CDOWF


Not included in Exchange 2007.


Windows Workflow Foundation (WWF) and Microsoft BizTalk Server 2006


EXOLEDB


De-emphasized but still supported.


Exchange Web Services


MAPI


De-emphasized but still supported.


Exchange Web Services


Public Folders


De-emphasized but still supported.


Exchange Web Services


Store Events


De-emphasized but still supported.


Exchange Web Services


WebDAV


De-emphasized but still supported.


Exchange Web Services


Web Forms


Not included in Exchange 2007.


ASP.NET


WMI Providers


Not included in Exchange 2007.


Windows PowerShell and Exchange Server 2007 commands.


 

Monitoring event sink # 20 – MailMsg COM class


MailMsg – COM Class


The MailMsg COM class represents a message as it proceeds through the SMTP service.



  • The information within the MailMsg object is persisted to some physical location such as the file system using objects and file handles provided by the installed store driver object.

  • The MailMsg COM class is integral to the SMTP service and does not need to be implemented.

  • Transport and protocol event sinks use references to a MailMsg object to access information about the message and the message contents as it proceeds through the service to its final destination.

MailMsg – CoClass 


CLSID : 39b16f50-a8ba-11d1-aa91-00aa006bc80b


ProgID : Exchange.MailMsg


Inproc Server : %SystemRoot%System32inetsrvmailmsg.dll


Available Interfaces:



For more detailed information, please read this article.

Monitoring event sink # 19 – SMTPReg.vbs


Are you looking to register the SMTP event sink? Then we need to make use of script called “SMTPReg.vbs”. The following event management script demonstrates using the Server Extension Objects (SEO) to manage event bindings for the SMTP service.


Please click here to download the “SMTPReg.vbs

Monitoring Event Sink # 18 – How to write an OnArrival-type SMTP event sink in managed code (using Visual Studio.NET)


I found this wonderful article talks about “How to write an OnArrival-type SMTP event sink in managed code by using Visual Studio .NET 2003“. It’s an interactive article, with step-by-step ways of illustration to create event sink in Managed environment(.Net).


Note: This sample event sink can be used to handle incoming SMTP commands and messages and to process them as needed.


This article contains an overview of how to write event sinks for SMTP events in managed code by using wrappers that obscure some of the details of communicating with the unmanaged server.

SMTP Commands Part # 3 – List of Server reply codes


When we execute the SMTP command, we’ll receive a reply from the mail server in the form of a three digit number followed by information describing the reply.

For example,


250 OK

Please find the list of reply codes from the Server.




































































211


 A system status or help reply.


214


 Help Message.


220


 The server is ready.


221


 The server is ending the conversation.


250


 The requested action was completed.


251


 The specified user is not local, but the server will forward the mail message.


354


 This is a reply to the DATA command. After getting this, start sending the body of the mail message, ending with “rn.rn.”


421


 The mail server will be shut down. Save the mail message and try again later.


450


 The mailbox that you are trying to reach is busy. Wait a little while and try again.


451


 The requested action was not done. Some error occurs in the mail server.


452


 The requested action was not done. The mail server ran out of system storage.


500


 The last command contained a syntax error or the command line was too long.


501


 The parameters or arguments in the last command contained a syntax error.


502


 The mail server has not implemented the last command.


503


 The last command was sent out of sequence. For example, you might have sent DATA before sending RECV.


504


 One of the parameters of the last command has not been implemented by the server.


550


 The mailbox that you are trying to reach can’t be found or you don’t have access rights.


551


 The specified user is not local; part of the text of the message will contain a forwarding address.


552


 The mailbox that you are trying to reach has run out of space. Store the message and try again tomorrow or in a few days-after the user gets a chance to delete some messages.


553


 The mail address that you specified was not syntactically correct.


554


 The mail transaction has failed for unknown causes.

SMTP Commands Part # 2 – Using Telnet on port 25 to test SMTP communication


Please find the following steps and SMTP commands to test SMTP communication using Telnet on Port 25.


1.                   At a command prompt, type telnet, and then press ENTER. This command opens the Telnet session.


2.                   Type set localecho and then press ENTER. This optional command lets you view the characters as you type them. This setting may be required for some SMTP servers.


3.                   Type set logfile <filename>. This optional command enables logging of the Telnet session to the specified log file. If you only specify a file name, the location of the log file is the current working directory. If you specify a path and a file name, the path must be local to the computer. Both the path and the file name that you specify must be entered in the Microsoft DOS 8.3 format. The path that you specify must already exist. If you specify a log file that doesn’t exist, it will be created for you.


4.                   Type open mail1.fabrikam.com 25 and then press ENTER.


5.                   Type EHLO contoso.com and then press ENTER.


6.                   Type MAIL FROM:chris@contoso.com and then press ENTER.


7.                   Type RCPT TO:kate@fabrikam.com NOTIFY=success,failure and then press ENTER. The optional NOTIFY command defines the particular delivery status notification (DSN) messages that the destination SMTP server must provide to the sender. DSN messages are defined in RFC 1891. In this case, you are requesting a DSN message for successful or failed message delivery.


8.                   Type DATA and then press ENTER. You will receive a response that resembles the following



354 Start mail input; end with <CLRF>.<CLRF>


9.                   Type Subject: Test Sampleand then press ENTER.


10.               Press ENTER. RFC 2822 requires a blank line between the Subject: header field and the message body.


11.               Type This is a test message and then press ENTER.


12.               Press ENTER, type a period ( . ) and then press ENTER. You will receive a response that resembles the following:



250 2.6.0 <GUID> Queued mail for delivery


13.               To disconnect from the destination SMTP server, type QUIT and then press ENTER. You will receive a response that resembles the following:



221 2.0.0 Service closing transmission channel


14.               To close the Telnet session, type quit and then press ENTER.

SMTP Commands Part # 1- List of SMTP Commands


Please find the list of SMTP commands and its definitions, which can be used on multiple places. For example it can be used to check event SMTP sinks by sending mails.


SMTP commands
























































SMTP command


Command function


HELO


Sent by a client to identify itself, usually with a domain name.


EHLO


Enables the server to identify its support for Extended Simple Mail Transfer Protocol (ESMTP) commands.


MAIL FROM


Identifies the sender of the message; used in the form MAIL FROM:.


RCPT TO


Identifies the message recipients; used in the form RCPT TO:.


TURN


Allows the client and server to switch roles and send mail in the reverse direction without having to establish a new connection.


ATRN


The ATRN (Authenticated TURN) command optionally takes one or more domains as a parameter. The ATRN command must be rejected if the session has not been authenticated.


SIZE


Provides a mechanism by which the SMTP server can indicate the maximum size message supported. Compliant servers must provide size extensions to indicate the maximum size message that can be accepted. Clients should not send messages that are larger than the size indicated by the server.


ETRN


An extension of SMTP. ETRN is sent by an SMTP server to request that another server send any e-mail messages that it has.


PIPELINING


Provides the ability to send a stream of commands without waiting for a response after each command.


CHUNKING


An ESMTP command that replaces the DATA command. So that the SMTP host does not have to continuously scan for the end of the data, this command sends a BDAT command with an argument that contains the total number of bytes in a message. The receiving server counts the bytes in the message and, when the message size equals the value sent by the BDAT command, the server assumes it has received all of the message data.


DATA


Sent by a client to initiate the transfer of message content.


DSN


An ESMTP command that enables delivery status notifications.


RSET


Nullifies the entire message transaction and resets the buffer.


VRFY


Verifies that a mailbox is available for message delivery; for example, vrfy ted verifies that a mailbox for Ted resides on the local server. This command is off by default in Exchange implementations.


HELP


Returns a list of commands that are supported by the SMTP service.


QUIT


Terminates the session.


The following table lists the extended SMTP commands that Exchange makes available to the SMTP service.


Extended SMTP commands




















Extended SMTP command


Command function


X-EXPS GSSAPI


A method that is used by Microsoft Exchange Server 2003 and Exchange 2000 Server servers to authenticate.


X-EXPS=LOGIN


A method that is used by Exchange 2000 and Exchange 2003 servers to authenticate.


X-EXCH50


Provides the ability to propagate message properties during server-to-server communication.


X-LINK2STATE


Adds support for link state routing in Exchange.

Monitoring event sink # 17 – Sample for adding disclaimer for outoging SMTP messages – VBScript


   1:  “VBScript”>
   2:  Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
   3:    TextDisclaimer = vbCrLf & “DISCLAIMER:” & vbCrLf & “Sample Disclaimer added in a VBScript.”
   4:     HTMLDisclaimer = 

DISCLAIMER:
Sample Disclaimer added in a VBScript.”

   5:   
   6:     If Msg.HTMLBody  “” Then
   7:        ‘Search for the “” tag and insert our disclaimer before that tag.
   8:         pos = InStr(1, Msg.HTMLBody, “”, vbTextCompare)
   9:         szPartI = Left(Msg.HTMLBody, pos – 1)
  10:         szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) – (pos – 1))
  11:         Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII
  12:     End If
  13:   
  14:     If Msg.TextBody  “” Then
  15:        Msg.TextBody = Msg.TextBody & vbCrLf & TextDisclaimer & vbCrLf
  16:     End If
  17:   
  18:     ‘Commit the content changes to the transport ADO Stream object.
  19:     Msg.DataSource.Save ‘ Commit the changes into the transport Stream
  20:     EventStatus = cdoRunNextSink
  21:  End Sub
  22:  

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Monitoring event sink # 16 – Sample for adding disclaimers for outgoing SMTP messages – Visual Basic 6.0


Visual Basic 6.0 sample


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.
   
Msg.DataSource.Save

    EventStatus = cdoRunNextSink
End Sub