Text Email Attachment

Hi, I am wanting to receive an email attachment and get the contents of the attachment as a String. I have set up an email listener and am able to get the email from the getTransportInfo service. But it is still unclear to me as to how I get the attachment. I have attempted to get the transport/email/content and run a streamToBytes and a bytesToStream but this does not seem to help. Do I have to implement a custom content handler (I would prefer not to have to do this, b/c of time constraints). Thanks in advance.

What type of attachment you want to get. Is it a word doc, excel or simple text/html. You might want to set up the mime data and content type according to your needs/attachments.
Check the service in WmSamples package under mime folder. That would help.

cheers

Thanks for you help! I was able to use the streamToString service in the WmSamples package and this worked. Not sure why yet, but it worked. Thanks again.

Has anyone ever tried calling the getTransportInfo service and found that the InputStream supposedly containing the contents of the attachment is null???

Can you please elaborate a bit more on the question?
What is the your process doing?
Generally the contentStream will be in the pipeline and so we have to extract the data using this for textfile email attachment.

Regards,

RMG,

I wrote a service that calls the pub.flow:getTransportInfo service to get the email attachment information onto the pipeline (the service is associated with an email port). The “transport” record returned should contain the email attachment as an InputStream Java object in the field transport/email/content, but it is set to null instead.

I’ve used the InputStream object called “contentStream” that is mapped onto the pipeline by the content handler, but now I need to get the filename of the attachment for audit purposes but this is no longer available.

My question is… is it possible to still get the other information about the attachment, information that is normally returned by the getTransportInfo service?

Anything you can suggest would be greatly appreciated.

I believe you can extract the email attachment filename from the pipe (transport/email/filename)of the getTransportInfo service.
put a savepipeline after the getTransport service and you will see it.

HTH,

I dont know why the getTransportinfo service not showing filename parameter in the pipeline which it is supposed to show.
Can you upload the Email port settings screenshot?So that i can check the settings.

HTH,

RMG,

I’ve attached a screenshot of the port settings. Hope this helps to explain why things aren’t working as they should.

Thanks again.

email port screenshot
emailport_screendump.zip (46.6 k)

Paolo,

I have checked the settings and there is one change that i request you to test which is shown below.set this setting to No instead of Yes.

“Include email headers when passing message to content handler”—No

remaining other settings are looks fine.

If possible specify the PackageName as WmRoot.

HTH,

RMG,

Sad news. I tried changing the “Include email headers…” setting to “No” and even changing the Package Name to WmRoot, but still got the same results.

Interestingly enough, SAP have (finally!) sent me back a reply to an OSS note I created regarding this issue (attached), which seems to give an explanation as to why I’m getting the results I am r.e. the content of the attachment being null.

What I’ve inferred from their reply is that if I want to get all of the information about every single attachment I get sent all of the time, I’m going to need to:

  1. Create a new mime type X/Y in the sapbc/Server/lib/mime.type file to associate the attachment name to my new mime type, and
  2. Register a custom content handler for the X/Y mime type to process the raw email contents.

I know I’ve probably worn out my welcome with this, but I’d really appreciate your comments on this plan of attack. I’ve tried playing with content handlers from the basic SAP example, but I dont have any documentation or practical examples on how to implement one.

Thanks for your patience… :wink:

SAP OSS note reply
012002523100002255342004.txt (3.4 k)