Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsWindows Server 2003Windows 2000Windows NTSmall Business ServerVirtual ServerExchange ServerIISHost Integration ServerISA ServerSMSWSUSMOMWindows Media ServerSecurityCertification
Related Topics
SQL ServerMS WindowsMS OfficePC HardwareMore Topics ...

Windows Server Forum / Exchange Server / Development / July 2008

Tip: Looking for answers? Try searching our database.

Modification of the subject in a protocol event sink

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Dupont - 03 Dec 2004 16:06 GMT
Hello,
I'm trying ti write a protocol event sink that do the following
things:
  read SCL attribute fixed by IMF
  if SCL > 7
      add "*** SPAM ***" in subject
      add smtp header x-scl:<value of SCL>
  end if

I've understood that to have access to SCL I need to write the event
sink in C++ (this property is not able with VBScript)

I started with SampleFilter given in Exchange SDK and modified the
method OnSmtpInCommand of the class CSampleFilter this way:
***************************************
   hr = pIMsg->GetDWORD(dwCFBase + IMMPID_CFMP_CONTENT_FILTER_SCL,
                        &dwOldSCL);

   // Début modif SEB
   //if (dwSCL >= 0)
    //{

    hr = pIMsg->GetStringA(
               IMMPID_MP_RFC822_MSG_SUBJECT,
               sizeof(szMsgSubject) / sizeof(CHAR),
               szMsgSubject);

    strcat (szNewMsgSubject, szMsgSubject);

    hr = pIMsg->PutStringA(
               IMMPID_MP_RFC822_MSG_SUBJECT,
               szNewMsgSubject);
fprintf(stream, "TRA: %s\n", szMsgSubject);
fprintf(stream, "TRA: %d : %s\n", dwSCL, szNewMsgSubject);

    hr = pIMsg->Commit(NULL);
***************************************

the 2 lignes "TRA: ...." are well witten in a file so the code is
executed but the subject id not modified ...

Could someone tell me what I've done wrong ???

Thanks
Alex Zammit - 03 Dec 2004 23:49 GMT
To modify the subject you will need a Transport Event sink not a protocol
event sink. Something like OnArrival should do.

At a protocol level the email subject does not exist yet since that is part
of the mail content itself.

regards,

Alexander Zammit
Software Development Consultant
Developer for windeveloper TNEF View
http://www.windeveloper.com/

> Hello,
> I'm trying ti write a protocol event sink that do the following
[quoted text clipped - 40 lines]
>
> Thanks
Martin Dupont - 06 Dec 2004 16:43 GMT
Your answer surprise me,
with this code I'm able to read the subject :
hr = pIMsg->GetStringA(IMMPID_MP_RFC822_MSG_SUBJECT,sizeof (szMsgSubject) /
sizeof(CHAR), szMsgSubject);

I though this one could modify it :
hr = pIMsg->PutStringA(IMMPID_MP_RFC822_MSG_SUBJECT,szNewMsgSubject);
hr = pIMsg->Commit(NULL);

What are defferences between Transport an Protocol Sink?
does the event sink OnArrival could be written with C++ (it seems to be
necessary to access SCL property) ?

> To modify the subject you will need a Transport Event sink not a protocol
> event sink. Something like OnArrival should do.
[quoted text clipped - 8 lines]
> Developer for windeveloper TNEF View
> http://www.windeveloper.com/
Alex Zammit - 06 Dec 2004 18:52 GMT
In simple terms protocol events integrate when the server is transmitting
SMTP protocol commands such as HELO, FROM, RCPT.

With Transport events you integrate after that the message was completely
received. At a time when you have complete control on the mail.

Yes you can write it in C++.

> Your answer surprise me,
> with this code I'm able to read the subject :
[quoted text clipped - 23 lines]
>> Developer for windeveloper TNEF View
>> http://www.windeveloper.com/
Alex Zammit - 08 Dec 2004 16:08 GMT
I made some more checking on this issue.

Effectively it might be possible for you to change the subject through the
protocol sink you are using. I am saying might since I never programmed the
_EOD protocol sink myself and don't know if there is any catch I am
overlooking.

I think that instead of using PutStringA() to set the subject you will need
to use the WriteContent() / MapContent functionality to edit the message
stream directly.

Let me know how it goes!

> Your answer surprise me,
> with this code I'm able to read the subject :
[quoted text clipped - 23 lines]
>> Developer for windeveloper TNEF View
>> http://www.windeveloper.com/
koushal - 02 Jul 2008 06:58 GMT
Hi all,

To modify the subject of the mail, here's what you gotta do:

1. Call pIMsg->ReadContent(). This will give you the requested amount of
bytes from the actual mail.
2. Seach for the string "Subject: " in the read buffer.
3. Now all you have to do is write the read buffer back using pIMsg-
>WriteContent() but you only have to replace the "Subject: " string with
"Subject: <your new subject here>".
4. Make subsequent ReadContent() and WriteContent() calls to copy the rest of
the mail as it is.
5. Finally, call Commit().
You'll have the message subject modified in the OnSmtpInCommand sink itself.
No need to write an OnArrival sink.

>Hello,
>I'm trying ti write a protocol event sink that do the following
[quoted text clipped - 40 lines]
>
>Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.