Distinct offers Network Monitor, the ONLY natural language Protocol Analyzer, ONC RPC for C++, .NET and Java, and IntelliTerm, the fastest Terminal Emulator for TN3270, TN5250 and VT420 on the market.

Distinct VIT: MIME Control: OnRecvBody

   Products   Downloads   Sales   Support   About us
  VIT



        
 

Summary

Receive the contents or filename of the extracted message body and any attachments.

Description

The OnRecvBody event occurs in response to calling the ExtractMessageEnd method. This event will occur during the extract message process to deliver the contents or filename of the message. It will also occur to deliver the file content or filename of any attachments the message may have.

The MIME ActiveX control will first extract the message header and body. The Mime ActiveX control fires the OnRecvHeader event to set the message properties. The body will be saved to the Destination directory (set in the call to the ExtractMessageStart method) and the OnRecvBody event will be fired to deliver the file name. If the Destination was set to NULL the MIME ActiveX control will then deliver the message by firing the OnRecvBody event one or more times to deliver the contents of the message body. The MIME ActiveX control will then similiarly fire the OnRecvHeader and OnRecvBody events to deliver any extracted attachments.

The Buffer parameter will contain the data or the filename, and Length will be set to the length of buffer. The IsFile parameter specifies whether a filename, or file contents is being delivered. If IsFile is 0 then the actual content of the message or attachment is being delivered; otherwise if IsFile is 1 the name of the file that contains the message or attachment is being delivered by this event.

To abort the extract message, set the Action property to ACTION_ABORT (or call the Abort method) during this event. The action in progress will be canceled and no further such events will occur.

Technical Note

If the message to be extracted is of type multipart or "message/external-body" the sequence of the OnRecvHeader and OnRecvBody events may differ. In case of multipart messages a OnRecvHeader event can be followed by another OnRecvHeader event instead of a OnRecvBody event. After MIME ActiveX control fires the OnRecvHeader event with the initial header, the sequence will be OnRecvHeader event followed by an OnRecvBody event unless there is a part with no body or if there is a nested multipart in which case an OnRecvHeader event may be followed by another OnRecvHeader event. The first body part is usually treated as the message body. The extraction of the rest of the body parts will follow same sequence. The MIME ActiveX control will automatically decode any encoded body part.

Similarly if the message is of type message/external-body then the initial OnRecvHeader event will be followed by an OnRecvHeader event instead of an OnRecvBody event.

Note that the general sequence of upcalls will be OnRecvHeader event followed by an OnRecvBody event unless there is a part with no header or an empty body, in those special cases a OnRecvHeader event may be followed by another OnRecvHeader event or a OnRecvBody event may be followed by another OnRecvBody event. It is the application's responsibility to keep track of, and decide how to treat the data received in each OnRecvBody event. The application can so this by checking the ContentType property after each OnRecvHeader event.

If the message is a non-MIME message then the attachments will be extracted and the MIME ActiveX control will fire the OnRecvHeader event followed by the OnRecvBody event. Note that for non-MIME messages only the Encoding and the Filename properties will be set by the OnRecvHeader event.

For non_ MIME messages, the attachment files that are not uuencoded will have a .TXT extension and the uuencoded files will be renamed to their original names after they are uudecoded. If renaming fails then the uudecoded file will have either a .ATF or .UUE extension.

For MIME messages, the MIME ActiveX control will first try to find the name of the attached file in the header. If there is one then the attachment file is given that name. If the filename does not exist, or if there already exists a file with the same name, then the file will have some temporary name, the application can check the FileName property to find the suggested name of the attachment file.

A file encoded in binhex40 generally has two parts, data fork and resource fork. The MIME ActiveX control will first decode the data fork and fire the OnRecvBody event (the Length parameter of will be set to 0 to indicate the end of data fork), then the resource fork, if present, will be decoded and delivered with OnRecvBody event.

If the message is a partial message then the MIME ActiveX control will only fire the OnRecvHeader and OnRecvBody events when it receives the reassembled entire message.

Example

' HeaderInfo is a structure for the attachment name, encoding used and the content type
' see the MIME sample for the definition

Sub Mime_OnRecvBody (Buffer As String, Length As Integer, IsFile As Integer)
' receive message body
If MsgBodyDone = False Then
If (Buffer = "")

MsgBodyDone = True
Else If (IsFile = 0) Then
Message = Buffer
Else

Message = "Message File: " & Buffer & Chr(10)
End If
' display message
MsgBox Message, 64, "Sample Program"
Exit Sub
End If

' send attachment filename
If AttachDone = False Then
If Buffer = "" Then
AttachDone = True
Else If (IsFile = 0) Then
Message = Buffer
Else

Message = "Attachment Received: " & Buffer & Chr(10)
End If
' display message
MsgBox Message, 64, "Sample Program"
Exit Sub
End If
' display message
MsgBox Message, 64, "Sample Program"

End Sub



Browse FAQ

Related Products
Mail Objects

Recommended Add-On
Network Monitor,
Protocol Analyzer


Raves
"The night before I went on summer holiday we had to make some 'last minute' configuration changes to approx. 300 routers, a tedious job to do manually with telnet. We went along with MS Excel containing a list of IP-adresses to the routers, and the VIT telnet-component. One hour later the VBA-application (small is beautiful) was working, and after another hour all of our routers were updated with the new configuration. I just say a big "Thanks" to you all for a good sleep that night."
Eirik Brendholen, Ergo Integration AS

"We conducted a test session to compare the performance of similar products, and Distinct's product was better!" [more]
Dr. Shyam Sunder, Carnegie Mellon University

"Together with Distinct, we were able to offer our users an ideal soution to enabling them to connect to Yahoo! Pager, and to do so both quickly and reliably." [more]
Brian Park,
Producer of Yahoo! Pager, Yahoo! Inc.


  8/20/2008   Legal notices | PRIVACY Policy | Networking News |