Skip to Content
Author's profile photo Thomas Jung

Receiving E-Mail and processing it with ABAP – Version 610 and Higher

Introduction
This week we have taken a look at two different ways of sending E-mails from ABAP. But what people may not realize is that it is just about as easy to receive E-mails. The setup and sample that I am going to present here is based upon the WebAS 610 and higher technology. All of my samples were created on a 620 system.

For another example of this technology you should have a look at the weblog CRM: Inbound mail processing – Attach files to Opportunity by Gregor Wolf.

Configuration
Just like with sending E-mails, there is a little bit of configuration that must be done before we get started. You probably want to go ahead and make sure that your system is already configured for sending e-mails via SMTP before you even start any of this configuration. Once again we have the excellent resource of OSS note 455140. Not only does it have instructions for setting up outbound e-mail, but it also has a nice section on inbound.

The first thing we need to do is setup a user. This is the user that all the inbound processing requests will run under (This is section 2.A in OSS Note 455140). I named my user SAPMAIL. I gave the ID the required S_A.SCON profile in addition to any other profiles it will need to carry out the processing we are requesting in our e-mail.

Next we need to configure our SAPConnect Node in Transaction SICF. We will change the SAPConnect node to run under the user we just setup in the previous step. The following is a screen shot of our SAPConnect Node:
image

Step 5 of the OSS note states that you need to setup routing rules in your corporate mail server to redirect emails to your WebAS. This is true and necessary for receiving mails from the Internet. But for our test we can bypass this step. Our MS Exchange people are very busy and don’t like to be bothered with requests for new rules. If you are inside your network you should be able to route an E-mail to your WebAS using its full Domain Name. For this example I am going to send a mail to my D15 system. It’s full DNS name is kww-d15s.kimball.com. Therefore to route mails to this system without a rule in our Exchange system, I just need to address them as the following: test@kww-d15s.kimball.com.

Inbound Processing
We should be about ready to setup the configuration that tells the WebAS what program to execute upon Inbound Mail arrival. We can do this configuration from Transaction SCOT once again. In SCOT we choose Menu: Settings->Inbound Processing. This configuration table allows us to setup inbound processing rules based upon the recipient address and/or document content type. You then just supply the name of the class that you want to process this request. Your selection of classes will be limited to those that implement the interface, IF_INBOUND_EXIT_BCS and both if its methods, CREATE_INSTANCE and PROCESS_INBOUND. The following is a screen shot of our configuration table.
image

Example Application
I thought that it might be fun to give you an example implementation of this code that would actually be somewhat useful. Have you ever been in a meeting or at lunch when you get a call that something is wrong with a system that you support. Wouldn’t it be nice if you had a quick, easy way to check your system status from a wireless PDA or cell phone. Well now you can! We are going to write an e-mail handler that will send you back the process overview (SM50) upon request.

We will start by creating a global class that I called ZCL_MAIL_INBOUND_SYS_CHECK. Like we said before it must implement interface IF_INBOUND_EXIT_BCS. That will give us two constant attributes (GC_CONTINUE and GC_TERMINATE), one static method (CREATE_INSTANCE) and one instance method (PROCESS_INBOUND). The way this exit class works is that the SAP Inbound mail handler will first call our static method to request an instance of our class(CREATE_INSTANCE). It then calls the instance method (PROCESS_INBOUND) with all the details about the incoming message (sender, content, attachments, etc.).

Attributes
The following is a screen shot of our global attributes. We only add one static attribute that keeps a pointer to our own instance. We will reuse this single instance during our CREATE_INSTANCE method. That way we only have one instance of the class at any time.
image

CREATE_INSTANCE
This is the first of our two interface methods. This is the static method that will return a pointer to an instance of class. If an instance doesn’t already exist, it will create one. The following is our code:

PROCESS_INBOUND
This is the main instance method that will be called to process our inbound email. We start off with our local data declarations. Then we grab a pointer to the E-Mail Reply object that has already been created for us:

Next we are going to do a little check on the sender address. We only want to reply if the sender address contains our company’s domain or the one for our cell phone provider. Hopefully this will cut down on the chances that our WebAS will get on someone’s SPAM list.

Now we want to start building our reply. We are just going to submit SM50 and grab its list output. We will then convert the list to HTML and insert it into our reply object. Now most of the process to build the reply I put in a separate method (SEND_REPLY) for reuse. We will look at this code in just a minute.

We follow this up with some error handling.

Just incase anyone wants to cut and paste the code, here is the complete method all together.

SEND_REPLY
SEND_REPLY is our last method and the only one that didn’t come from the interface definition. I broke this code out just to make it a little more reusable. We will take in a pointer to the reply object, the subject, and the message content.
image We start off with a few local data declarations. Then I set a different sender into the reply message. I don’t want the e-mail coming back from the user that this method is currently running under (SAPMAIL). I want it to appear to have come from our support mailbox. Therefore I change the sender to a different SAP User (KEGSAPSUP).

Next we build the message body, the message attributes, and then send it on its way.

In the end I send my email to D15Status@kww-d15s.kimball.com and I receive the following back a second or two later:
image

Assigned tags

      143 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hi Thomas,
      These were the blogs which i was searching for.Thanks for your reply to my query in forum.That was really helpful.
      Thanks a lot again

      Best Regards
      Yogesh Mali

      Author's profile photo Former Member
      Former Member
      Eventually I managed to do it following your example !
      Once I did something similar using transaction S028 (a BP was created based on the information contained in an email)

      If I do have time (euphemism for I might not be able to do it due to my limited experience with ABAP)  I'd like to get ‘adventurous’ and send the report (perhaps even parameters) I want to get in the subject of the email.

      Mihai

      P.S. the sending of the email worked without 'commit work' in method SEND_REPLY.

      Author's profile photo Thomas Jung
      Thomas Jung
      I guess I could have been clearer on the Commit Work.  It will work without the commit work because ABAP will perform a commit for you at the end of your processing.  However much of the BCS processing only happens on commit.  Therefore there are exceptions that are not thrown until the commit work is performed.  I like to call the commit work so that I have an opportunity to catch the BCS excpetions.
      Author's profile photo Former Member
      Former Member
      I forgot to say that the report does not look so nice (no colors) but I suppose it is something minor.

      "I like to call the commit work so that I have an opportunity to catch the BCS excpetions".

      So how would you do it ? I mean if you have a sample of code.

      Author's profile photo Thomas Jung
      Thomas Jung
      Its in there.  That's why I close my main routine with the following block:
      CATCH cx_os_object_not_found cx_alert_recipient_unknown cx_document_bcs  ....

      That should catch the errors thrown by the BCS and handle them somewhat gracefully. 

      Your table doesn't have colors?  Mine does. It could be a problem with the template that you specify in the WWW_HTML_FROM_LISTOBJECT.  

      Author's profile photo Former Member
      Former Member
      I was wondering, after the program compiled successfully, where can we check the incoming mail?

      Rgds,
      Hapizorr Rozi Alias

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Well it is up to your inbound processing handler class to determine what to do with the inbound mail content. It isn't automatically saved.  If you want to save and view the incomming content, then you would have to build that functionality into your class.
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Then it will work.  Its been quite some time since I've even seen a 4.7 system.  As stated in a opening of this blog, however: The setup and sample that I am going to present here is based upon the WebAS 610 and higher technology. All of my samples were created on a 620 system.

      Author's profile photo Subbarao Ilam
      Subbarao Ilam

      Thank you.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      Super blog. I am using the same email functionality. But, i am trying to use SUBMIT (program) . My z program i am using which will send a mail with attachments to the vendor. This z program i am submitting it to our class which we are configuring in SCOT.

      When i tested this, i am getting mail delivery error. If i remove that submit statement, then our class is workgin fine. But i want my z program to send mail to vendor.

      When i executed my z program via SE38. It is working fine.

      Please suggest.

      Thanks,

      Prabu

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      There is nothing in email processing itself which should be impacted by the SUBMIT (program).  I don't really have enough details about your program to troubleshoot, but I also don't see how it could be related to the email itself. 

      Author's profile photo Former Member
      Former Member
      Great coding and it works out-of-the-box!
      Copy&Paste... 😉

      Would it be possible to parse the incoming Mail also?
      I want to answer with different reports and I would like to use one inbound-mail-adress rather than different Mail-Adresses.
      Therefore I would have to parse the body of the mail to detect which report to send - and probably which parameters to use...

      And afterwards I would like to delete the processed mail...

      Any ideas or suggestions?

      Thanks in advice!

      Author's profile photo Thomas Jung
      Thomas Jung
      Sure you can even process file attachments.  In the following code I get the document content and then loop through the body parts looking for a particular file attachment.  I then get the content for this attachment and process it.

      **** get document
              li_document = io_sreq->get_document( ).

      **** get no. of body parts
              l_parts = li_document->get_body_part_count( ).

      **** Read which body part contains the file we are looking for
              do l_parts times.
                attribute = li_document->get_body_part_attributes( sy-index ).
                if attribute-subject cs 'cr.csv'.
                  move sy-index to currency_attachment.
                endif.
              enddo.

      ****Read the actual content
              ls_content = li_document->get_body_part_content( currency_attachment ).
              attribute = li_document->get_body_part_attributes( currency_attachment ).

      ****  check for text content
              if not ls_content-cont_text is initial.
                loop at ls_content-cont_text into l_contline.
                  concatenate l_content l_contline into l_content.
                endloop.

      Now as far as your second question about deleting the email; that I'm not sure about. I would have to do a little research.  There are SAP jobs to purge mail.   I would imagine that you could schedule one of these to clean up these messages.  I am kind of just guessing. I would have to talk to our Basis guy since he handles the cleanup jobs. 

      Author's profile photo Former Member
      Former Member
      Hello Thomas,

      thank you for your reply!
      But you have some parts in your coding I can not really handle at the moment:

      >**** Read which body part contains the file we
      >do l_parts times.
      >attribute = li_document->get_body_part_attributes>( sy-index ).
      >if attribute-subject cs 'cr.csv'.
      >move sy-index to currency_attachment.
      >endif.
      >enddo.

      As written in the ealier posting I want to parse the body of the email. As described in the object model, the body also will be a part of "get_body_part" like an attachment?

      You are using "attribute-subject" to identify the attachment you want to deal with - do you know the subject of the body_part which contains the "real" body of the mail? Would it be probably a fixed number which can be used instead of the integer you get while searching for the attachment? Thus I would be ablke to use something like this "get_body_part_content(2)"?

      Thanks in advice!
      Markus

      Author's profile photo Thomas Jung
      Thomas Jung
      Yes I believe that the main body of the message should always be the first body part.  However if you look at all the SAP classes that do this as well (cl_alert_confirm_by_mail, cl_appointment_reply, and cl_uws_form_runtime_mail), they always do the same thing.  They get the number of parts and then loop through them looking for some attribute. 
      Author's profile photo Former Member
      Former Member
      Hello Thomas,

      once again thanks for the hints and SAP classes to look up!

      1) cl_alert_confirm_by_mail
      This class loops through _all_ body-parts via get_body_part_content().
      If I choose to take the same coding, loop through all parts wouldn´t this raise an error trying to parse something like a csv or a JPEG e.g.?

      2) cl_appointment_reply
      This class filters via doc_type of the body-part-attribute. doc_type is defined as "type bcss_dbpa" and this is a structure, therefor I won´t be able to look up the potential doctypes at all, because there is no check-table included.

      3)cl_uws_form_runtime_mail
      also loops through all body-parts

      I will try the first version (looping though all body-parts) first...
      But I would prefer to filter by using the doctype... ;-))

      Thanks for the help!
      Markus

      Author's profile photo Thomas Jung
      Thomas Jung
      It sounds like some debugging might be in order.  I think you could assume that the first indexed body part is always you main body.  Therefore you could use the get_body_part_content(1).  (Or would that be a zero based index?).  On way to find out would be to debug.  However you will find that acutally debugging in this class is not possible.  You can't just set a breakpoint.  The code will be excuted under you SMTP SICF Node ID.  I the only way I have been able to debug is to set an endless while loop in the code.  Then when it gets stuck in the while loop I attach the debugger to the running process.  I then change the value of the variable in my while condition and continue debugging.
      Author's profile photo Former Member
      Former Member
      In Mime Messages there is nothing like a main body part. It might contain a Multipart/Mixed Container with a plain an and an HTML attachment. Also the order is not that reliable. Some MUAs send no cleartext section other then "this email is in html" as the first alternative.

      Therefore it is best to loop and extract the first txt document as long as you know you can expect that in your mail, otherwise you should most likely deal with HTML parts.

      (This is however a generel rule, not related to SAPs inbound mail falcility).

      Gruss
      Bernd

      Author's profile photo Former Member
      Former Member
      Hello Thomas,

      Thanks for the weblog on parsing emails. Our requirements are an extension to this. We want to attach the atttachments of the mail to an activity document. Can you please tell us how to carry this out.

      Regards
      Siddhesh

      Author's profile photo Thomas Jung
      Thomas Jung
      I don't know how much help I am going to be since I am going to ask the question: what is an activity document?  It sounds like you are going to want functionality specific to some other solution - activity documents.  I have shown you how to extract attachments, but I would need more details on what exactly you are wanting to do to help out further.
      Author's profile photo Former Member
      Former Member
      Hello Thomas

      I am sorry as I wasnt clear about the scenario. We will be receiveing emails in our SAP inbox. We will parse them and if there are attachments (like word documents) to the mail, then we want to attact those word documents to CRM business activity.
      OR alternatively attach the entire email to the activity record in CRM.

      An activity is a CRM specific transaction .

      We have found a funct. module CRM_ICSS_UPLOAD_SR_ATTACHMENT, which seems to be useful but we havent gone through it in detail.

      Thanks

      Author's profile photo Thomas Jung
      Thomas Jung
      I'm afraid I won't be able to help you much because you are looking for CRM specific functionality.  I have never worked on, nor do I have access to a CRM system. 
      Author's profile photo Gregor Wolf
      Gregor Wolf
      Hi,

      I've just posted a Weblog CRM: Inbound mail processing – Attach files to Opportunity which uses the fuction module CRM_ICSS_UPLOAD_SR_ATTACHMENT to attach files from an E-Mail to a CRM Opportunity.

      Regards
      Gregor

      Author's profile photo Former Member
      Former Member
      Hi,
      Can any body tell me how to catch the mail attachment( EXCEL , CSV etc..) content, whenever mail comes to the SAP Office inbox...
      that means our program will trigger when the new mail comes to SAP office inbox..

      Thanks in advance..

      syam.

      Author's profile photo Thomas Jung
      Thomas Jung
      As far as how to trigger a program when new mail arrives, that is kind of the whole purpose of this weblog.  Mail attachments have already been discussed in this discussion section earlier.  Here is a small code sampe:
      **** get document
      li_document = io_sreq->get_document( ).

      **** get no. of body parts
      l_parts = li_document->get_body_part_count( ).

      **** Read which body part contains the file we are looking for
      do l_parts times.
      attribute = li_document->get_body_part_attributes( sy-index ).
      if attribute-subject cs 'cr.csv'.
      move sy-index to currency_attachment.
      endif.
      enddo.

      ****Read the actual content
      ls_content = li_document->get_body_part_content( currency_attachment ).
      attribute = li_document->get_body_part_attributes( currency_attachment ).

      **** check for text content
      if not ls_content-cont_text is initial.
      loop at ls_content-cont_text into l_contline.
      concatenate l_content l_contline into l_content.
      endloop.

      Is this what you are looking for?

      Author's profile photo Sergey Korolev
      Sergey Korolev
      That's what I was looking for!
      Thank you very much Thomas for sharing your knowledge!

      Best regards, Sergei

      Author's profile photo eddhie kurnianto
      eddhie kurnianto
      hi Thomas,

      this is very helpfull blog.
      many thanks for you for sharing your knowledge.

      hey, i got a question, could the similar mechanism can be used for inbound sms handling ?

      please advice

      regards

      eddhie

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Doubtful, unless you could externally to your SAP system somehow bridge your SMS to SMTP.  This mechanism is only designed to listen for SMTP traffic.
      Author's profile photo eddhie kurnianto
      eddhie kurnianto
      do you have any idea for handling inbound sms ?
      please advice

      many thanks in advance

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I'm afrad tha this is not a topic I have ever researched. Sorry.
      Author's profile photo periyathai muniappan
      periyathai muniappan

      Hi Thomas,

      I have a requirement that external third party system sends email to our c service account. I should read those email and send it to repective person

      I have done all the configuration and created a Z class that you have suggested.

      My email ID was configured in SCOT transaction.

      I tried to send an email using outlook and checked whether I got any reply back or not as per your blog.

      But I didnt get any reply. I dont know when my breakpoint in this program will get triggered.

      Please help me how to debug and how to achieve this functionality

      Regards,

      Peri

      Author's profile photo Former Member
      Former Member
      hi Thomas,

      this description is exactly what i searched for. But now i am searching for a possibility to debug the code which i inserted into the new class.

      Can you tell me how to debug the code ?

      br
      Norbert

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      You will find that I discussed debugging already in the comments of the blog.  I will just plagurize myself a bit:

      However you will find that acutally debugging in this class is not possible. You can't just set a breakpoint. The code will be excuted under you SMTP SICF Node ID. I the only way I have been able to debug is to set an endless while loop in the code. Then when it gets stuck in the while loop I attach the debugger to the running process. I then change the value of the variable in my while condition and continue debugging.

      Author's profile photo Former Member
      Former Member
      Hello Thomas,
      first of all a great blog. Congratulations!
      It should be possible to debug the class. Enter the user of the mail node in SICF in your settings for external debugging (e.g. in SE80) and then add an external breakpoint in the class. The debugger should be started the next time when an e-mail is received. In our system (NW2004s, 7.00) this worked very well. I don´t know if this also works on a 6.20 system.

      Best regards,
      André

      Author's profile photo Former Member
      Former Member
      Great Blog...as always!  I made this fit an application where the user is updating a task via their cell phone.  The user is informed when the task is updated or why it was not.  It works fine except for an additional email that is sent (for a total of 2) to the user "554 Transaction failed (in reply to end of DATA command)".  If I exit right before the SEND_REPLY method is called, no messages are sent.  If I put EXIT as my first line of code in the SEND_REPLY method, only the 554 message is sent.  I'm sure I'm missing something quite basic, but I have gone over all of the traces I can think of and I can find no errors.  Please help.
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I can't say that I have seen the 554 error before.  Could this be something that your mail server is generating? Perhaps it doesn't like something about the way the communication is working with the NetWeaver system?  What mail system do you use?

      You also might try turning on trace in transaction SCOT and looking at the detailed log of the trace. This might give you some clue as to if the 554 is being generated with the mail system runtime of the NetWeaver server.

      Author's profile photo Former Member
      Former Member
      Hi,

      After configuring our system for Inb-Outbound email i'm getting the same failure 554. Without sending back an email everthings works fine, but with sending back an email the 554 failure coms-up the mail is sent back but there is also this failure email.

      Question did you manage to solve the 554 problem
      <<#5.5.0 smtp;554 Cannot process message in SAP System>>

      I would like to hear from you!

      Regards,
      Jeroen Cosijnse

      Author's profile photo Former Member
      Former Member
      Hi We are facing the same issue, did you figure out what its regarding to?

      5.5.0 smtp;554 Transaction failed

      Author's profile photo Former Member
      Former Member
      Hey Brett,

        I know it's been a while since you worked on this, but I'm running into the same issue.  We have a group set up in outlook CRMMAIL5@companyname.com.  When it receives an email, it gets forwarded to CRMMAIL5@crmdev.companyname.com.  We have a CRM user set up.  CRMMAIL5.  The inbound email goes into the user's inbox and also kick off my exit processing, which updates the status of a quote.  I am not sending any reply emails.  I've commented out that code, but I am still getting the 554 exchange message, because it appears that exchange expects some sort of notification that the email was delivered.  So I get the error

      Generating server: ex2k7.ompanyname.com

      crmmail5@crmdev.companyname.com
      crmdev.companyname.com #554 Cannot process message in SAP System ##

      Is this how you set up your scenario?  Where you able to fix your problem ever?  Appreciate the help.

      Cathy

      Author's profile photo Former Member
      Former Member

      Hi Thomas,Pradeep Ram

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      >Did you mean that I can send mails from Outlook client to this email id, if I am within the Intranet??
      Yes

      >Please give me some pointers of where to check for problems
      Turn on the inbound trace option in SCOT.  That will tell you if your mail is reaching the SAP system but then having a problem.  If you don't see anything in the trace, then the problem is within your mail system.  This being external to SAP (and varying greatly from customer to customer) I can't offer much advise other than to go talk to your email administration team.

      Author's profile photo Former Member
      Former Member
      Hi!

      Excelent Blog but, how do I can know my full hostname?

      Thanks!

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Ask someone at your company who would know - usually the Basis or Network admin. 
      Author's profile photo Former Member
      Former Member
      Thanks Thomas,

      Last question: you prepare all, you create a class implementing the interface...and, the method of the class 'runs' authomatically? I mean, when a mail enter into SAP system, implemented class execute authomatically?

      Regards.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      In short - yes.  The ICM receives the email and instaniates the configured class to handle the incomming request.  There are no batch jobs or anything to schedule because the ICM basically acts as a constant communication gateway for all incomming and outgoing HTTP/HTTPS/SMTP communications.
      Author's profile photo Former Member
      Former Member
      Hi Thomas,

      First, thanks for this blog very helpfull form us .

      I'm facing a problem and i don't find a solution while i want to send mail in my inbound process.

      My process is receiving mail into SAP with Adobe Document Forms inside. I extract the PDF and process it . When the process is finished i have to send several mail to several user .
      The send of mail is not only for this process, so i create an Object in order to do it .
      So in the inbound process, i create an instance of my other object , that works fine for updatin data but that doesn't work for sending the mail .

      I'll try to do it with a program where i call the same method as inbound mail and that works fine .

      Any idea to help ?

      Regards

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I'm not exactly sure what you are trying to describe. Are you having problems sending new mails from within the inbound process?  That may well be the case.  You can really only use the reply object to create outbound mails from the inbound process.

      If you need to send new outbound mails consider wrapping that logic into an RFC and call it with STARTING NEW TASK.

      Author's profile photo Former Member
      Former Member
      Thank you for blog.
      May you advise, are there similar possibility in ABAP 46c?

      Thnks,
      Denis

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      No the BCS classes were not delivered until WebAS release 6.10.  I have a separate blog on the older APIs that you would use for 4.6C and below:
      Sending E-Mail from ABAP - Version 46D and Lower - API Interface
      Author's profile photo Former Member
      Former Member
      sorry, I am interested about processing of inbound mails.
      I need to process a received mail with my programm. There is a EDI recepient type in SO28, but I cannot understand how to customize EDI for the mail processing.
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      My mistake.  I didn't look close enough at which blog this was.  Sorry but the inbound mail procesing functionality described here did not exist on 4.6C.  It is specific to the SMTP processing of the WebAS.  I don't know if there was a way to do something similar with the old SAPConnect and APIs and I've evidently never worked with the EDI Recipient Type that you are describing.
      Author's profile photo Subbarao Ilam
      Subbarao Ilam

      Hi Thomas,

      I have a requirement, where I want to process a inbound e-mail and complete a workflow using inbound e-mail exit. I am working in SAP 4.7 system. could you please suggest me whether the inbound e-mail processing work in SAP 4.7 using interface IF_INBOUND_EXIT_BCS.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      No, not possible.  There was ICM to process the inbound request until Basis 6.10.

      Author's profile photo Subbarao Ilam
      Subbarao Ilam

      Hi Thomos,

      The system I am working on is SAP 4.7/Basis 6.20.

      Author's profile photo Former Member
      Former Member
      Thomas,

      First great blog.  Seems very straight-forward.  I'm having a bit of an issue however and hopefully you have a couple minutes to respond.

      I'm confused on a couple of topics.

      1) Is there a relationship between the SAPMAIL user you used for transaction SICF (Service Data - Username) and the D15Status@kww-d15s.kimball.com user you used in your Exit Rules for Inbound Processing?

      2) Does the D15Status user actually exist in transaction SU01 as a valid dialog user in SAP?  If so do you have to maintain the e-mail field in SU01 in the communication box of the address data?  If so do you simply define it (per your example) D15Status@kww-d15s.kimball.com?

      I've configured everything per your blog as well as the OSS Note but everytime I send an e-mail from within my company's firewall I get the response from the mail daemon that "User Unknown".

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      1. No, no relationship at all.  Every process in an ABAP system must run as some User.  the SAPMAIL user is simply the user that the inbound processing class will run under once triggered. 

      2. No the D15Status user doesn't exist in the system.  This is just a mapping of the mail address name to the class that should execute for that name.

      Not working:  Make sure that hostname for your system is correctly used as the domain of the email address.  In most mail servers this will cause the routing to occur.  I was using Microsoft Exchange.  I got with the Exchange team and they were able to trace the communications for me when I originally had some communications problems.  Also depending upon your mail server, you might need to setup routing rules.  You can activate trace within SCOT as well, but I suspect that the mail is not even reaching your SAP system.

      Author's profile photo Former Member
      Former Member
      Correct, I activated the trace within SCOT but it doesn't appear the mail is reaching the SAP system at all.

      If the D15Status user doesn't exist in the SAP system why would the smtp plug in try to deliver it to higher levels of SAP?  Wouldn't it validate whether the user actually exists anywhere and trigger an error?

      Again thanks for taking the time to answer questions you've probably answered 100 times already.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      No it doesn't have to exist at all.  The email address is only used for matching against the exit rules in SCOT - to determine what class should handle the inbound email.  You will only get an error if it doesn't find a matching configuration.

      Author's profile photo Former Member
      Former Member
      Hi Thomas,

      i'm look for a class, witch takes over the attributes of a task from Outlook.
      For example: Date beginn/end, Priority....
      Can you support me?
      Thank you
      Margit

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I'm afraid I don't know anything about Outlook task or their data format.
      Author's profile photo Former Member
      Former Member
      Hi Thomas,
         Thanks for the great blog. this was very helpful.
      i want to access at a later point, an email that has arrived in the system. What you ahve shown is the inbound processing. For example while inbound processing i want to save some unique identifier of the email and based on this, i would like to access this email at a later point. How can i do this?
      Regards,
      Nithin
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      You are probably going to want to just record the information into a custom database table.  That would seem like the simpliest approach.
      Author's profile photo Former Member
      Former Member
      You can see all the inbound emails using the transaction SOIN. Hope this helps.

      Thanks,
      Hemanth

      Author's profile photo Former Member
      Former Member
      Hi Thomas,
               I have question like, if some company uses third party mail server,then they won't have the chance to change/make routing rules through which the external mails could be reached to our SAP inbox.

      Then what could be the SMTP SETTINGS that could be done to receive external emails or else ultimately we have to go for the use third party software's that perform this type of task. please help me.

      Regards,
      Arif.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I'm not sure I undestand your question.  Everyone has to use a third party mail server as SAP doesn't create a mail server. I can't tell you the correct settings for routings in your third party mail server software - because I don't even know what software you are using. You should consult the administrators at your company of that particular mail software.  In order to address the SMTP server of you SAP system you use the configured hostname and SMTP port setup by your basis admins and viewable in transaction SMICM.
      Author's profile photo Former Member
      Former Member
      Thanks a lot Thomas for your prompt reply,

      I'll inquire about the configured ports and the host name and also ask them that could we change that particular third party mail server settings or not.

      Regards,
      Arif.

      Author's profile photo Former Member
      Former Member
      Thomas,

        I know it's been a while since you worked on this, but I'm running into the same issue.  We have a group set up in outlook CRMMAIL5@companyname.com.  When it receives an email, it gets forwarded to CRMMAIL5@crmdev.companyname.com.  We have a CRM user set up.  CRMMAIL5.  Email address in SU01 is CRMMAIL5@companyname.com.  The inbound email goes into the user's inbox just fine and also kicks off my exit processing, which updates the status of a quote, just fine.  I am not sending any reply emails.  I've commented out that code, but I am still getting the 554 exchange message, because it appears that exchange expects some sort of notification that the email was delivered.  So I get the error

      Generating server: ex2k7.ompanyname.com

      crmmail5@crmdev.companyname.com
      crmdev.companyname.com #554 Cannot process message in SAP System ##

      Do I have something set incorrectly?

      Thanks.

      Cathy

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      It is difficult to say what Exchange might be expecting back.  Make sure that you are setting the e_retcode.  Try experimenting with statuses for e_retcode using the different constans of if_inbound_exit_bcs=>gc_*

      Author's profile photo Former Member
      Former Member
      Hello Cathy,
      Hello Thomas,

      We are also trying to do the same thing here.
      We have made all the necessary configurations and have the routing rules in exchange also in place. The email reached the SMTP service but bounces back with a message ‘User Not Found’.
      In the SCOT inbound trace also, there is no record of email reaching the SAP system.

      Do you have any idea regarding this issue? Will the standard R/3 users work? I am sending a mail on myuser@serverdns.com but it says no user found. Do we have to register the R/3 user with WebAS or something like this?

      Author's profile photo Former Member
      Former Member
      Hi thomas,

      Thanks for the blog.As shown in the blog, i have created the class with the methods.And in the interface method i just gave some dump message.Now i am trying to send mail through SBWP.Please tell me if this dump should show up in ST22 or not.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      If you are producing a dump via a message it should always show up in ST22.
      Author's profile photo Former Member
      Former Member
      Hi Thomas,

      As always, it's a great blog.

      I was trying to find the possible ways to debug the incoming email and have come across this excellent blog. I have gone through the comments section where one of the debugging options have been discussed.

      A little more research on this front resulted in another option to debug the inbound emails. Just for the benefit of developer(like me) who are looking for other possible ways to debug, here you go.
      --------------------------------------------------
      1) Debugging can be switched on by setting 'DBG+' in the transaction input field in the transaction SCOT. Attention: It will be applied for all incoming emails in SAPConnect. One should as soon as possible switch off the debugging by setting 'DBG-'. {More info available when you enter DBG+ in SCOT}

      2) Make sure the service user id created (SAPMAIL in this case)have debug authorizations.

      3) Set a break-point in PROCESS_INBOUND method.

      4) As soon as SAP receives an email, you can see a work process in SM50. Run SM50 with your own user id(need not login as SAPMAIL) and select the respective work process and debug (Program/Session-> Program-> Debugging)

      5) A new debugger session opens up where in you need to set the variable 'DEBUG' to 'X' and F8. Control should stop at break-point set in the method 'PROCESS_INBOUND'.
      --------------------------------------------------
      I could not find these steps in other blogs, so thought of sharing this. If this is a repost, please ignore.

      Regards,
      Hemanth

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Thanks so much for giving back by sharing this learning with everyone. 
      Author's profile photo Former Member
      Former Member
      Here is a slight variation I use to debug the inbound emails.

      Make sure user of the SAPCONNECT service in SICF has debug access.

      I believe the user also has to be a dialog user.

      To turn on debugging Go to transaction SCOTT and enter DBG+ in the input field

      Go to class CL_SMTP_EXT_SAPCONNECT (SE80 -> choose class/interface)

        Expand method folder and double click on HANDLE_REQUEST  method

        Place an external break point on the line of code "while debug = sx_false". Make sure you set the external debug user to the user running the SAPCONNECT service in SICF.

      Place an external break point in the desired exit class configured in SO50.

      In SE80 select the desired class.

      Expand method folder and double click method PROCESS_INBOUND

      Place an external break point on desired line of code.

      Send an email to SAP.

      Debugging session should appear.  Set the DEBUG flag to X to exit loop.  Then hit F8.  The debug session should proceed to your break point set earlier in the exit class from SO50.

      Turn off debugging when finished by going to SCOTT and entering DBG- in input field.

      Author's profile photo Former Member
      Former Member
      Hi

      I have a scenario in which inbound email is in HTML format and contains an image.

      How do we separate out the text and image(hex) content while parsing the email document.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      They are already separate.  The Text of an HTML email will only contain HTML markup.  The Image is a separate binary object that should be in the mail as a MIME attachment.
      Author's profile photo Former Member
      Former Member
      Hi,

      While sending the email, I have embedded image (hex format) in the email using CL_BCS (As in your blog Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface). Image is displayed in the email using HTML tag .

      When user replies to this email, the inbound email also contains this image. While reading the email contents using ls_content = i_document->get_body_part_content() it returns ls_content-cont_text[] empty. It returns hex data in ls_content-cont_hex[]. How do I interpret this data and how to separate out HTML markup contents and image contents.

      Also, when the incoming email does not contain image, it correctly returns email body contents in ls_content-cont_text[].

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Are you sure the email is still HTML based and hasn't been converted to Rich Text by an external mail client?

      Converting the cont_hex is really going to depend upon what the inner content is.  If it is still HTML then you should just be able to convert the cont_hex back into something more easily processed use CL_BCS=>CONVERT SOLIX_TO_XSTRING. Assuming the content is still text based, you should then be able to convert the XSTRING to a STRING using the following code:

        data: convin  type ref to cl_abap_conv_in_ce,
      call method cl_abap_conv_in_ce=>create
              exporting
                input       = xstring
              receiving
                conv        = convin.

            call method convin->read
              importing
                data = string.

      Author's profile photo Former Member
      Former Member
      Hi,

      Thanks for replying.

      I could not find CL_BCS=>CONVERT SOLIX_TO_XSTRING.

      Also, the email is in HTML format.

      Author's profile photo Former Member
      Former Member
      Hi

      I am working in SRM and in SRM we dont have this class CL_BCS_CONVERT. I referred to the method SOLIX_TO_XSTRING of this class in R3 and used the same code to convert content_hex[] into xstring. But this does not work. It does not convert the text content correctly and returns garbage hex data.

      I need help to understand - "Why the text/html markup is not returned in internal table content_text[]?" When user replies to email from Outlook he selects email format as HTML, that means inbound email is in HTML format.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      CL_BCS_CONVERT is a BASIS class and therefore should be present in any ABAP based system.  Are you sure you don't have the class? Perhaps you are on an older release level that doesn't have this class.

      >It does not convert the text content correctly and returns garbage hex data.
      How do you know it is garbage?  It is is still binary data, so it wouldn't be human readable.

      Author's profile photo Former Member
      Former Member
      Have you made any progress with separating the text from the hex content.  When I send and inbound message in text format.  The method get_body_part_content returns cont_text as desired.  However, when I send an inbound message in html format I do not see any content in the cont_text[] or in the cont_hex[] tables and the GET_BODY_PART_ATTRIBUTES method returns docsize as 0.  I can call the AS_MIME_MESSAGE method from the class CL_SEND_REQUEST_BCS to return the MIME.  But, I don't know how to parse the MIME.  I was hoping I did not have to parse the MIME and that looping through the body parts method and calling the method GET_BODY_PART_CONTENT would return each part for me.  Please respond if you have made and progress.

      Thanks.

      Author's profile photo Former Member
      Former Member
      Hi Thomas,

      First, We would like to thank you for this blog.

      we followed every step from the blog and created a zclass in which we implemented the interface -
      IF_INBOUND_EXIT_BCS.

      The first method  'IF_INBOUND_EXIT_BCS~CREATE_INSTANCE' is getting triggered. We inserted a record in a database table. In the second method,
      'IF_INBOUND_EXIT_BCS~PROCESS_INBOUND' also we inserted a record in another database table. But this method is not getting triggered. No record is inserted in this db table.

      Is it the problem with authorizations or with the profile 'S_A.SCON' ?

      Could you please tell us the reason.

      Thanks & Regards,
      Ram.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I really can't say why it isn't trigger in your application/system. I have listed what I know about using this functionality already in this blog. 
      Author's profile photo Former Member
      Former Member
      Hi Ram,

      I am facing similar problem. The CREATE_INSTANCE is getting called but there after the method PROCESS_INBOUND is not getting called. Have you been able to find out the issue ? or solved the problem ? Request your input on this issue.

      Regards,
      Anirban

      Author's profile photo Former Member
      Former Member
      Thanks Thomas for the blog.

      We can process plain text emails and emails with attachments.  However, message content sent with only HTML in the body is missing.  I see the following error in transaction SOIN in the SAPConnect WorkFlow Trace.  Log Action: CL_BCOM_MIME->GET_CODEPAGE_TO_CH; Log Text: Since charset is unknown, codepage 1101 (us-ascii) accepted.  It appears the MIME object is parsed incorrectly. 

      When the method CL_BCOM_MIME_SINGLEPART=>ANALYZE_HEADER_CONTENT_TYPE is called for field CONTENT-TYPE the following parameter is returned: FIELD_NAME: CHARSET; FIELD_BODY "us-ascii"Content-Transfer-Encoding: quoted-printableTEST BODY HTML.  For some reason the entire message body with US-ASCII is set as the value of the character set. 

      Later an EXIT I configured in SO50 is called to read the document.  The GET_BODY_PART_COUNT method shows the document as having 1 part.  The attributes of the document are: DOC_TYPE = txt; BINARY = {blank}; SUBJECT = html subject; Filename = html subject.txt; DOCSIZE = 0.

      Do you have any idea how I can read the HTML based inboud email?  I can see the data in SOIN when I press the display MIME data button.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Sorry, but I don't have any advice I can share on this situation. I would recommend posting your question in the SDN Forums.
      Author's profile photo Former Member
      Former Member
      The problem with the HTML MIME messages was resolved last year.  Our Exchange team was truncating the inbound messages which made it impossible to parse out a MIME messages into it's parts. 

      Since then, we have built on the inbound functionality. We use the functionality so our users can approve requests through their BlackBerry or any other mobile or email device by clicking on an APPROVE or REJECT link to send inbound emails or by just replying with certain keywords such as APPROVE or REJECT.

      Also, we have an application where we allow users to send in photos of defective products to automatically create quality notifications.  The inbound attachments are placed in the Document Management System, the email text is placed in the long text of a quality notification and the DMS documents are linked to the Quality Notification.  We also scrape the subject line to determine the model number of the defective product.

      Author's profile photo Former Member
      Former Member
      Dear Thomas ,

      First of all nice blog and this helped me in many business process .

      But today I am writing you because I stuck inbetween some process .

      Implimenting the PO release process by Offline Configuration but not able to release my PO using BAPI_PO_RELEASE . Have return the code in the class and which is using the interface IF_INBOUND_EXIT_BCS . Everything is working fine but when I use this BAPI I get the delivery failure mail back to my inbox .

      Please help is this the case that I cant exceute BAPI in this . Because this is working fine when I raise the event then PO get release .

      Thanks & Regards
      Ankit Jain

      Author's profile photo Former Member
      Former Member
      In case if someone is looking for the transaction to access all the emails received by SAP, it's SOIN.

      Hope this helps.

      Thanks,
      Hemanth

      Author's profile photo Former Member
      Former Member
      Hi people, I found this blog (btw. good job with it) when I was searching for solution of my problem - I have mailbox (lets consider it is mysap(at)gmail.com) and from standard SAP ERP (so no XI...) I want to login to this mailbox and get emails from it. Is that somehow possible? Because manuals like this require sending of mail directly to SAP system where they are processed. But my problem is, that SAP, where I need to process emails, is standalone system behind NAT and firewall without any mail server. The best I can do is to set that mailbox (mysap(at)gmail.com) to redirect emails somewhere and maintain rules on firewall and router for letting some communication to come in...
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      > I want to login to this mailbox and get emails from it.

      That's not really feasible.  SAP mailbox is really only intended to send mail out to full mail servers or to receive mail for process via a class (as in this blog).  I suppose you could setup an auto forward from your gmail and then in the inbound rules place these mails into your SAP inbox.  SAP won't really be able to go and retrieve your mail from gmail however.

      Author's profile photo Former Member
      Former Member
      Thanks much for reply, although I was affraid of this kind of reply :). Ok, so I try it with redirecting. Do you have any tips&tricks how to do it? Because as I said, my SAP is not directly exposed to internet (so no valid FQDN...). I am also not sure which protocol is used between mailservers and therefore, in which protocol will be redirected mail sent to my router (is it standard SMTP?) and on which port. In my best hopes, I think it will require just redirecting from mailbox to my router IP (for example test@111.222.333.444), on router redirect it to server with SAP and then continue with this blog manual. Am I correct?
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      No advice I'm afraid.  These are questions that you should discuss with your network and system administrators.
      Author's profile photo Former Member
      Former Member
      Ok, solved. It was almost as I hoped. Standard redirecting of emails is performed using SMTP protocol (TCP port 25), so it is just required to "make path" for emails on routers/switches/gateways/... to reach server with SAP. And from this point it is just continuing with this guide (once more thanks for it). So finnaly, when everything works, email send to mymail@gmail.com is redirected to sap_username@my_network_ip (or of course, can be used DNS to avoid working directly with IP), in my network is redirected TCP port nr. 25 to SAP server and on this server are performed steps from this guide. Hope this will help somebody in future.
      Author's profile photo Former Member
      Former Member
      Hi Thomas,

      It is an excellent blog. We are trying to implement this in our project. The configuration was done by basis as provided in the blog and the Z class was created and assigned in the Exit rules in the inbound processing as mentioned in this blog.

      We have a user for inbound processing ‘I_INBND_MAIL’

      Now I try to send a mail to I_INBND_MAIL@(DNSaddress).

      But the mail does not come into the sap system. I get the postmaster reply saying that the mail is undelivered.

      I even tried to send mail from my sap system, using sap business workplace.

      I found that in SOST, the mail was in transmitted state. But still it was not delivered to that mail id as I got undelivered mail.

      Can you suggest me the possible corrections needed to be done.

      I also have the doubt if mail-id mentioned in the exit rules of inbound processing and the inbound processing user(SAPMAIL in this case and I_INBND_MAIL in my case) has any relationship.

      Thank you

      Arun

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      >But the mail does not come into the sap system. I get the postmaster reply saying that the mail is undelivered.

      See Step 5 of the instructions that you do generally need routing rules in your corporate mail server:
      Step 5 of the OSS note states that you need to setup routing rules in your corporate mail server to redirect emails to your WebAS.

      >I also have the doubt if mail-id mentioned in the exit rules of inbound processing and the inbound processing user(SAPMAIL in this case and I_INBND_MAIL in my case) has any relationship.

      No, no relationship.  The inbound processing user is attached to the inbound node and will be used regardless of the mail-id.

      Author's profile photo Former Member
      Former Member
      Thanks for the reply.

      But you have mentioned in the blog the following :
      "If you are inside your network you should be able to route an E-mail to your WebAS using its full Domain Name. For this example I am going to send a mail to my D15 system. It's full DNS name is kww-d15s.kimball.com. Therefore to route mails to this system without a rule in our Exchange system, I just need to address them as the following: test@kww-d15s.kimball.com"

      How do you achieve this? I tried sending mail from SAP sytem to the internet mail id(D15Status@kww-d15s.kimball.com in your case). Is it the correct way to do?

      Thank you

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Yes that worked in my corporate environment at Kimball, although ulitmately we setup an alias with rules in Exchange. However this working will really depend upon your corporate network and email client configuration. If you are having routing errors reaching your SAP system inbox, you should really pull together your Basis and Email teams (and possibly network team) and hash out the proper configuration for your environment.
      Author's profile photo Former Member
      Former Member
      Thank you.

      Hope this would resolve my issue.

      Regards

      Arun

      Author's profile photo Former Member
      Former Member
      Hello  Thomas,

      First off, excellent blog. We have setup without issue and have several email processes setup between SAP and mail clients. Thanks for posting this guide to facilate setting this up.

      I have a semi-related question. One of the processes we have built is email based workflow approval. Functionally it is working fine, and visually looks good in Outlook and Blackberry. On the iphone however the rendering of the outbound email has issues. We are sending an HTML email with multipart mime attachments, the attachments (images) shows inline on Outlook and Blackberry however on the iphone, they display as attachments at the bottom of the email, making the Approve and Reject buttons appears as broken links, although you can still click through them. I am thinking its related to the email headers needing to be more specific on Apple Mail, in particular the Content-Disposition of the attachments. SAP is creating them as such:

      --=_92D54309943DB74CBD377E9BC2685805
      Content-Disposition: attachment; filename="ZBN1.JPG"
      Content-Type: image/jpeg; name="ZBN1.JPG"
      Content-Transfer-Encoding: base64
      Content-Description: ZBN1

      but from what I read Applie in needing them to be inline opposed to attachment, why can't everyone behave the same 🙂

      I looked at the message source in SOST but the meta data is not there at that point so I am assuming when the SMTP plug-in processes the emails, it is applying them. Do we have any control on that? The attachements are being embedded using that CL_DOCUMENT_BCS ADD_ATTACHMENT method. I looked in the class and don't see any parameters on that method, as well as in SCOT for the SMTP setup.

      Any help is greatly appreciated.

      Kind regards,
      Lewis
      PS. Again, really great blog.

      Author's profile photo Former Member
      Former Member
      Figured it out - just for reference you use:

      cl_document_bcs=>create_from_multirelated

      After creating the attachements with an instance of cl_gbt_multirelated_service via the add_binary_part method.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      Sorry for the delay answering - I've been out all week for SAPPHIRE NOW in Orlando.  Thanks for posting that you figured it out and sharing the answer.  I was just about to begin to research your question when I saw you response.
      Author's profile photo Former Member
      Former Member
      Hello, Thomas!
      Thank you for this issue. It helped us to improve our mail functinality.
      Can you give us right way if we want to receive mails with attachments, check its formats (Excel, Word etc.), analyse or check its (attachments) contents (for *.xls/*.xlsx, maybe for *.doc/*.docx) against special rules and then save it as DMS document?
      Author's profile photo Former Member
      Former Member
      Hello? Is anybody blogging?
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I don't really understand why you would ask if anyone is blogging.  You asked a question that really wasn't even a question - but a request for a new topic. I would suggest that you post general question in the SCN forums. Also you should probably search as there are topics and blogs that cover some parts of what you describe already (the discussion on DMS storage in particluar).
      Author's profile photo Former Member
      Former Member
      Thank you Thomas for the answer. I can shorten my question because I have been searched DMS forum and another resources. We dont use dms content server.
      And is it a right way to:
      1. operate with binary search when we want to make special checks inside the file?
      2. put through file to dms like a binary content?
      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author
      I'm afraid I don't completely understand your questions.

      1.  Binary search - do you mean like read table ... binary search?  If so this has nothing to do with binary content.  It has to do with the search method used to process records in the internal table.  What kind of special checks do you want to perform?  If the content is still fundamentally text based you probably should just cast it to a string.  Otherwise it really depends upon the internal format of the file type you are working with.

      2. Put a file to DMS?  It though you just wrote that you don't use DMS. Why are you now asking me about DMS?

      Really these questions aren't directly related to this blog. For general questions, you should really post them in the forums.  The questions at the end of a blog are for asking clarification on points within the blog - not open ended question areas.

      Author's profile photo Former Member
      Former Member
      1. for binary search I meant that we want to analize internal content of files attached to inbound mail (if attachment is excel file we want to look into and of course internal content of excel file is a table so that before sending and saving this to dms we want to make a decision how many rows are filled correctly, to find special symbols, and so on and make this test on the fly when our trigger get instance, start working)
      2. in dms we can use two type of standart storage: sapdb, content server. we dont use content server so that we have problem how to cut from mail and send attachment file to dms.
      Author's profile photo Former Member
      Former Member
      Binary search - do you mean like read table ...  - like read table of attachment if attachment is an excel file
      Author's profile photo Erik Hoven
      Erik Hoven

      Hi Thomas,

      🙂 nice blog....!!!

      We want to store the inbound email in SAP DMS.

      (We always receive a reference to a notification we like to store in a DIR object link)

      Can that be possible without first create a temp file ?

      ...create the DIR from the data-stream ?

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Sorry but I don't have the answer to that question.  It doesn't really have anything to do with the inbound email itself but instead the functionality of SAP DMS and whatever APIs you are using to store objects there.

      Author's profile photo Erik Hoven
      Erik Hoven

      ...thanx Thomas. 😉

      But can I aks you (maybe more relevant)....

      ...is there an attribute representing the full email in a binary or hex format.

      I have studied CL_DOCUMENT_BCS

      Please advice.

      Best regards,

      Erik

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      >is there an attribute representing the full email in a binary or hex format.

      No becasue that isn't how the mail is structure.  It is a multi-part MIME.  Therefore you must call GET_BODY_PART_CONTENT for the number of body parts. You can get the content in either text or binary format from this method.

      Author's profile photo Former Member
      Former Member

      Erik, yes you can create a DIR with an original w/o first writing the data stream to a file.  We use the API CVAPI_DOC_CREATE.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      Thanks alot for this detailed blog on the inbound email processing.

           I have one concern, the user under which the inbound process runs needs to be dialog user or a background user?

      I am trying with dialog user which is giving the dump as "dynpro_send_in_background".

      I am working in solman 7.0.

      Thanks and Regards.

      Piyush R. S.

      Author's profile photo Gregor Wolf
      Gregor Wolf

      Dear Piyush R. S.,

      whatever the functionality is that you need to implement it must work without the requirement of a SAP GUI. So no dynpro processing is possible. The best would be to use RFC enabled function modules like BAPI's.

      Best regards

      Gregor

      Author's profile photo Former Member
      Former Member

      Dear Gregor,

      Thanks alot for the quick reply.

      I am trying to change the status of the incicent through email.

      For this I have used two function modules "CRM_OREDR_MAINTAIN and CRM_ORDER_SAVE" which SAP is also using in the process of change incident. I found these FMs in the debug mode.

      I am getting the dump in the program "RSCONN01", which seems somthing related to the SAP connect settings in SICF.

      for now I am looking if I have missed something in the configuration.

      Thanks and Regards.

      Piyush R.S.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I seriously doubt this error is related to the user.  I believe a background user should work fine.  More likely you are calling functionality within your processing logic which isn't designed to run "dark".  There is a call screen, GUI Control command, or dialog being used. 

      Author's profile photo Former Member
      Former Member

      Verymuch Informative.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

                       The blog was really helpful.Thanks a ton.I have a small question.I have implemented the above logic and found that the exit class is being triggered when a mail comes in from Ms-outlook or gmail ie.. external sources in general.If i send a mail to the from sap to the user's inbox where this exit class is implemented and all settings are made,

      I found that this is not getting triggered.Can you please explain if this is a valid behaviour or is there any error in configuration?

      Regards,

      Dushyanth

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      >If i send a mail to the from sap to the user's inbox where this exit class is implemented and all settings are made,

      I found that this is not getting triggered.

      When you say you are triggering this from SAP - you mean the send functionality of the SAPGUI?  If so this probably isn't going through the SMTP plugin because its coming from the system itself. Therefore the communication type wouldn't be Internet in the SCOT inbound exit configuration table.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

                       Thank you for the response.Yes i was sending mail using the from the transaction 'SBWP'--Business Workspace.I have noticed another problem.I just wanted to process the inbound emails with high priority and skip otherwise.I have noticed a attribute

      DOC_IMP in CL_SEND_REQUEST_BCS . This is a private attribute and the method which returns this attribute value GET_DOC_IMP is also private.I found another attribute priority

      but it is not being set to a different value when i send a inbound mail marked with high priority.Is there any another way to get the priority of inbound mail?

      Regards,

      Dushyanth.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I'm sorry it has been quite a few years since I've worked in this area.  I'm not up to date on all the features available nor could I suggest a way to get the priority of the inbound mail.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      I am facing an issue as in the screen shot below, (error from trace log), any advice?

      I am trying to convert the email inbound as ZMIV incident.

      /wp-content/uploads/2013/12/error_348370.jpg

      Regards,

      Kumar

      Author's profile photo AJAY SHARMA
      AJAY SHARMA

      Thanks Thomas for such wonderful blog. I have implemented this functionality successfully in ECC,

      I have one more requirement, could you please share your view for that.

      Requirement : Need to save Inbound email in Application server (Linux) once we analyzed all data from Inbound email. I searched lot but didn't get much help on this.

      Regards

      Ajay Sharma

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      You have the mail content in the inbound exit. Just use normal ABAP DATASET command to write it to a text file on the OS file system.

      Author's profile photo AJAY SHARMA
      AJAY SHARMA

      Thanks Thomas .

      I am getting content in two internal table CONT_TEXT and  CONT_HEX (For Multiple attachments). And my requirement is to save whole email as .msg extension so  that Content Manager (ECM) can pick this file and save in its database for other application. 

      Thanks & Regards

      Ajay

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      .msg format is Microsoft created and controlled format. You will have to study their documentation on that format and how to create it.

      https://msdn.microsoft.com/en-us/library/cc463912%28v=exchg.80%29.aspx

      Author's profile photo Former Member
      Former Member

      Hello Thomas !!

      I am having a similar requirement of receivng inbound emails in SAP.

      I have created one user SMTPUSER and have assigned the profile S_A.SCON.

      I have asigned it an email id ctmprod@wf.com in its user profile.

      I also have SICF sapconnect node set up for user SMTPUSER and SMTP node activated.

      I am sending an email to ctmprod@wf.com from outlook.

      the email id ctmprod@wf.com is though the email id for microsoft user CTMPROD and there is no such user SMTPUSER in microsoft exchange server.

      I am not receiving any inbound emails in SAP.

      Can you please guide me what is going wrong here?

      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hello Sandip,

      please talk to your Exchange Server admins. They have to setup a send connector to the ABAP System. Then they can create a contact in exchange with a forward to the created send connector.

      Best regards

      Gregor

      Author's profile photo Former Member
      Former Member

      Hello Gregor!

      thanks for the information. Do i need to provide then any details from ABAP system side?

      I mean the SMTP server name or the host name or anything else before they can set up a send connector?

      Thanks

      Sandip

      Author's profile photo Gregor Wolf
      Gregor Wolf

      They need the FQDN and the Port of the ABAP SMTP Server.

      Author's profile photo Former Member
      Former Member

      Thanks Gregor ! I will get in touch with the server team. Will post the updates.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      I know this is an old thread, but your blog on this topic is still applicable.

      I have a question on Step 5, which is to forward emails to SAP. You have mentioned that there's no need to create a routing rule if it's within network. The issue we have is we're using Office 365 and there's no routing rule option to forward emails to our SAP server. Can you please explain how to achieve this? Thanks.

      Author's profile photo Vlad aka Skif
      Vlad aka Skif

      Hi, guru,

      Sorry, but I don't understand piece "* build document for reply" - for what?

      It's for include into test program?

      wbr

      Vlad

       

       

      Author's profile photo Former Member
      Former Member

      Hi Thomas @thomas.jung3,

      I'm a junior CRM consultant, just got my certification 3 months ago...

      Well i really need help! i have to integrate the groupware with outlook 2010 and working with MS 2007, i tried to follow some steps on the web but in vain, it would be great if you can give me steps that worked and which would be easy to understand for me as a new SAP associate.

      Thanks in advance,

      Have a good day!

      Author's profile photo Sandeep Kumar
      Sandeep Kumar

      Hi Thomas,

       

      Thank you for such an amazing blog!!

      If we are receiving mail from external user (outlook ID), do they need to have SAP user ID in SAP system ?

      Our requirement is to receive approval /rejection from external user who are not authorized in SAP.

      Regards

      Author's profile photo Sandeep Kumar
      Sandeep Kumar

      Hi Thomas,

       

      Thank you for such an amazing blog!!

      If we are receiving mail from external user (outlook ID), do they need to have SAP user ID in SAP system ?

      Our requirement is to receive approval /rejection from external user who are not authorized in SAP.

      Regards

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Technically this setup doesn't require a user to be created for each email.  There is just one batch user that is setup for the SMTP node and processes all incoming requests. However if your concern is the licensing implications, I would suggest you review the materials on Indirect Access and as also with licensing questions, discuss with your SAP account executive if anything is in doubt.

      Indirect Access Guide for SAP Installed Base Customers

      Author's profile photo Sandeep Kumar
      Sandeep Kumar

      Thanks Thomas!!This means We do not require any API or webservices to communicate with outlook right?

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      No. No interface to Outlook.  The ABAP Application Service has an SMTP server built into.  You might only need to setup forwarding/routing rules in Exchange.

      Author's profile photo Sandeep Kumar
      Sandeep Kumar

      Thank you