Current position:  Home > Default > Sending mail to the user-id

Sending mail to the user-id

Time:October 11
Advertisement
Hi Guys,
       I Have The Requirement Like ,I need To Send The Data As A Mail From the ABAP Program,and also i need to set the  sender address different from the login-id,how to set the sender address different from login-id..please help with the coding..
<REMOVED BY MODERATOR>
thanks&regards
srinivasulu.j
Edited by: Alvaro Tejada Galindo on Jan 24, 2008 9:32 AM
Advertisement
hi
good
pls check this report.
: Report  ZSAPTALK                                                   :
: Author  SAPdev.co.uk                                               :
: Description :                                                      :
: Send mail message to SAP mail inbox.                               :
:                     Please visit www.sapdev.co.uk for further info :
REPORT ZSAPMAIL NO STANDARD PAGE HEADING.
TABLES: DRAD,
        QINF,
        DRAW,
        SOUC,
        SOFD,
        DRAP.
DATA: P_RETURN_CODE LIKE SY-SUBRC.
data: d_username LIKE DRAP-PRNAM.
mail declarations
DATA : BEGIN OF NEW_OBJECT_ID.         " the newly created email object
        INCLUDE STRUCTURE SOODK.
DATA : END OF NEW_OBJECT_ID.
DATA : BEGIN OF FOLDER_ID.             " the folder id of the outbox
        INCLUDE STRUCTURE SOODK.
DATA : END OF FOLDER_ID.
DATA : BEGIN OF REC_TAB OCCURS 5.     " the table which will contain the
        INCLUDE STRUCTURE SOOS1.       " information on the destination
DATA : END OF REC_TAB.
DATA : BEGIN OF OBJECT_HD_CHANGE.      " the table which contains the
        INCLUDE STRUCTURE SOOD1.       " info for the object we will be
DATA : END OF OBJECT_HD_CHANGE.        " creating
DATA : OBJECT_TYPE LIKE SOOD-OBJTP.    " the type of object
DATA : BEGIN OF OBJHEAD OCCURS 5.      " the header of the object
        INCLUDE STRUCTURE SOLI.
DATA : END OF OBJHEAD.
DATA : BEGIN OF OBJCONT OCCURS 0.      " the contents of the object
        INCLUDE STRUCTURE SOLI.        " i.e. the text etc
DATA : END OF OBJCONT.
DATA : BEGIN OF OBJPARA OCCURS 5.      " formatting options
        INCLUDE STRUCTURE SELC.
DATA : END OF OBJPARA.
DATA : BEGIN OF OBJPARB OCCURS 5.      " formatting options
        INCLUDE STRUCTURE SOOP1.
DATA : END OF OBJPARB.
DATA : BEGIN OF T_MAIL_TEXT OCCURS 0,  "Message table for messages to
        STRING(255),                   "user via mailbox
       END OF T_MAIL_TEXT.
Parameter: p_uname like sy-uname.
**START-OF-SELECTION
START-OF-SELECTION.
    d_username = p_uname.
    PERFORM POPULATE_EMAIL_TEXT.
    PERFORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
    PERFORM CREATE_AND_SEND_MAIL_OBJECT.
      FORM POPULATE_EMAIL_TEXT                                      *
      Inserts text for email message                                *
FORM POPULATE_EMAIL_TEXT.
  CLEAR T_MAIL_TEXT-STRING.            "puts a blank line in
  APPEND T_MAIL_TEXT.
  APPEND T_MAIL_TEXT.
adds failed list  on to end of success list.
  T_MAIL_TEXT-STRING = 'Test email message line 1'.
  APPEND T_MAIL_TEXT.
  T_MAIL_TEXT-STRING = 'Test email message line 1'.
  APPEND T_MAIL_TEXT.
  CLEAR T_MAIL_TEXT-STRING.            "puts a blank line in
  APPEND T_MAIL_TEXT.
  T_MAIL_TEXT-STRING = 'Header1    Header2    Header3'.
  APPEND T_MAIL_TEXT.
  T_MAIL_TEXT-STRING = '----
  APPEND T_MAIL_TEXT.
ENDFORM.
*&      Form  SETUP_TRX_&_RTX_MAILBOXES
  Ensure that the mailboxes of the sender (INTMGR) are set up OK
FORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
get the user no of the sender in order to add the mail to the
user name's outbox for future reference
  SELECT SINGLE * FROM SOUC
           WHERE SAPNAM = SY-UNAME.    "SAP name of a SAPoffice user
  IF SY-SUBRC NE 0.
    "Error finding the SAPoffice user info for the user
    MESSAGE E064(ZR53) WITH SY-UNAME.
    P_RETURN_CODE = 1.
    EXIT.
  ENDIF.
*Get the outbox No for the sender from the user No where the folder
                                       " type is an outbox
  SELECT * FROM SOFD WHERE OWNTP = SOUC-USRTP   "Owner type from ID
                       AND OWNYR = SOUC-USRYR   "Owner year from the ID
                       AND OWNNO = SOUC-USRNO   "Owner number from the I
                       AND FOLRG = 'O'."Output box
  ENDSELECT.
  IF SY-SUBRC NE 0.
    " Error getting folder information for the user
    MESSAGE E065(ZR53) WITH SY-UNAME.
    P_RETURN_CODE = 1.
    EXIT.
  ENDIF.
ENDFORM.                               " SETUP_TRX_&_RTX_MAILBOXES
*&      Form  CREATE_AND_SEND_MAIL_OBJECT
FORM CREATE_AND_SEND_MAIL_OBJECT.
  FOLDER_ID-OBJTP = SOFD-FOLTP.        " the folder type ( usually FOL )
  FOLDER_ID-OBJYR = SOFD-FOLYR.        " the folder year ( usually 22 )
  FOLDER_ID-OBJNO = SOFD-FOLNO.        " the folder no.
  OBJECT_TYPE     = 'RAW'.             " the type of object being added
build up the object information for creating the object
  OBJECT_HD_CHANGE-OBJLA  = SY-LANGU.  " the language of the email
  OBJECT_HD_CHANGE-OBJNAM = 'PS to DM Interface'. " the object name
mail subject 'Mass Linking of QA, pass/fail'
  MOVE TEXT-002 TO OBJECT_HD_CHANGE-OBJDES.
  OBJECT_HD_CHANGE-DLDAT = SY-DATUM.   " the date of the email
  OBJECT_HD_CHANGE-DLTIM = SY-UZEIT.   " the time of the email
  OBJECT_HD_CHANGE-OBJPRI = '1'.       " the priority ( highest )
  OBJECT_HD_CHANGE-OBJSNS = 'F'.       " the object sensitivity
F is functional, C - company sensitive
object_hd_change-skips  = ' '.       " Skip first screen
object_hd_change-acnam  = 'SM35'.    " Batch imput transaction
object_hd_change-vmtyp  = 'T'.       " Transaction type
add the text lines into the contents of the email
  CLEAR OBJCONT.
  REFRESH OBJCONT.
free objcont.      " added this to delete the mail contents records
  LOOP AT T_MAIL_TEXT.
    OBJCONT-LINE = T_MAIL_TEXT-STRING.
    APPEND OBJCONT.
  ENDLOOP.
  CLEAR OBJCONT.
build up the table of receivers for the email
  REC_TAB-RCDAT = SY-DATUM.            " the date to send the email
  REC_TAB-RCTIM = SY-UZEIT.            " the time to send the email
the SAP username of the person who will receive the email
  REC_TAB-RECNAM = D_USERNAME.
the user type of the person who will send the email ( USR )
  REC_TAB-SNDTP = SOUC-USRTP.
the user year of the person who will send the email ( 22 )
  REC_TAB-SNDYR = SOUC-USRYR.
the user number of the person who will send the email
  REC_TAB-SNDNO = SOUC-USRNO.
the sap username of the person who will send the email
  REC_TAB-SNDNAM = SY-UNAME.
get the user info for the receiver of the document
  SELECT SINGLE * FROM SOUC WHERE SAPNAM = D_USERNAME.
  IF SY-SUBRC NE 0.
    WRITE : / TEXT-001, D_USERNAME.    "usnam.
    EXIT.
  ENDIF.
the user number of the person who will receive the email ( USR )
  REC_TAB-RECNO = SOUC-USRNO.
the user type of the person who will receive the email ( USR )
  REC_TAB-RECTP = SOUC-USRTP.
the user year of the person who will receive the email ( USR )
  REC_TAB-RECYR = SOUC-USRYR.
the priority of the email ( highest )
  REC_TAB-SNDPRI = '1'.
check for delivery on the email
  REC_TAB-DELIVER = 'X'.
send express so recipient knows there is a problem
  REC_TAB-SNDEX = 'X'.
check for a return receipt
  REC_TAB-READ = 'X'.
the sap username of the person receiving the email
  REC_TAB-ADR_NAME = D_USERNAME.       "usnam.
add this receiver to the internal table
  APPEND REC_TAB.
  CLEAR REC_TAB.
call the function to create the object in the outbox of the sender
  CALL FUNCTION 'SO_OBJECT_INSERT'
       EXPORTING
            FOLDER_ID                  = FOLDER_ID
            OBJECT_HD_CHANGE           = OBJECT_HD_CHANGE
            OBJECT_TYPE                = OBJECT_TYPE
            OWNER                      = SY-UNAME
       IMPORTING
            OBJECT_ID                  = NEW_OBJECT_ID
       TABLES
            OBJCONT                    = OBJCONT
            OBJHEAD                    = OBJHEAD
            OBJPARA                    = OBJPARA
            OBJPARB                    = OBJPARB
       EXCEPTIONS
            ACTIVE_USER_NOT_EXIST      = 1
            COMMUNICATION_FAILURE      = 2
            COMPONENT_NOT_AVAILABLE    = 3
            DL_NAME_EXIST              = 4
            FOLDER_NOT_EXIST           = 5
            FOLDER_NO_AUTHORIZATION    = 6
            OBJECT_TYPE_NOT_EXIST      = 7
            OPERATION_NO_AUTHORIZATION = 8
            OWNER_NOT_EXIST            = 9
            PARAMETER_ERROR            = 10
            SUBSTITUTE_NOT_ACTIVE      = 11
            SUBSTITUTE_NOT_DEFINED     = 12
            SYSTEM_FAILURE             = 13
            X_ERROR                    = 14
            OTHERS                     = 15.
  IF SY-SUBRC NE 0.
    MESSAGE A063(ZR53) WITH SY-SUBRC.
    EXIT.
  ENDIF.
call the function to send the already created email to the receivers
  CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
            FOLDER_ID                  = FOLDER_ID
            OBJECT_ID                  = NEW_OBJECT_ID
            OUTBOX_FLAG                = 'X'
            OWNER                      = SY-UNAME
       TABLES
            RECEIVERS                  = REC_TAB
       EXCEPTIONS
            ACTIVE_USER_NOT_EXIST      = 1
            COMMUNICATION_FAILURE      = 2
            COMPONENT_NOT_AVAILABLE    = 3
            FOLDER_NOT_EXIST           = 4
            FOLDER_NO_AUTHORIZATION    = 5
            FORWARDER_NOT_EXIST        = 6
            NOTE_NOT_EXIST             = 7
            OBJECT_NOT_EXIST           = 8
            OBJECT_NOT_SENT            = 9
            OBJECT_NO_AUTHORIZATION    = 10
            OBJECT_TYPE_NOT_EXIST      = 11
            OPERATION_NO_AUTHORIZATION = 12
            OWNER_NOT_EXIST            = 13
            PARAMETER_ERROR            = 14
            SUBSTITUTE_NOT_ACTIVE      = 15
            SUBSTITUTE_NOT_DEFINED     = 16
            SYSTEM_FAILURE             = 17
            TOO_MUCH_RECEIVERS         = 18
            USER_NOT_EXIST             = 19
            X_ERROR                    = 20
            OTHERS                     = 21.
  IF SY-SUBRC EQ 0.
    MESSAGE I035(ZR53) WITH NEW_OBJECT_ID D_USERNAME. "usnam.
  ELSE.
    MESSAGE I036(ZR53) WITH D_USERNAME."      sy-subrc.
  ENDIF.
ENDFORM.                               " CREATE_AND_SEND_MAIL_OBJECT
thanks
mrutyun^

How to send Mail in case of Output Determination - Transmission medium 5

2015-10-11

Dear Friends, I have a below requirement. - Create custom output type having Transmission medium 5, which triggers on creation of order. - Write driver program attached to that output type that sends e-mail to the person who has created the order. -

Sending mail with multiple attachment

2015-10-11

hi. i want to send mail with multiple attachment. i m succeed in sending multiple attachment but the second pdf is not open. its given error like "This file is damaged and could not be open. pls check my code. and give the solution.... point should b

Sender Mail Adapter

2015-10-11

Hi,   I am working on Sender Mail Adapter. I have done the total configuration but unable to sucess the scenarios. In the CC monitoring, it is saying that "Not Intialised" Even though i send and receive the messages from My Lotus Notes Inbox. I

Sender Mail Adapter - forcing content as an attachement

2015-10-11

Hi all, We are using the Sender Mail Adapter to pull emails from the inboxes of some users of an exchange server.  We use the Mail Package option. We have noticed that the content of the emails are by-default added as attachments when there are no re

Sender Mail Adapter Configuration - Process Multiple Attachments

2015-10-11

Dear sirs, I need to process several attachments at the same mail message as individual payloads. In default configuration of sender mail adapter only the body of message is used as payload. So I added PayloadSwapBean Module at Processing Sequence an

Sender Mail adapter encounters MalformedInputException

2015-10-11

I have a sender mail adapter that processes the attached .csv file.  All is working fine.  I use FCC in module to convert the attachment and pass to an IDOC adapter for processing in SAP system. My problem is sometimes the sender mail CC fails with .

Sender "Mail" adapter - CSV file attachment

2015-10-11

Hi there I'm looking for some help in configuring a sender mail adapter that receives ".csv" files. I did read some blogs that mention using the "PayloadSwapBean" module to read the mail attachment instead of the mail content. My probl

Sender Mail Adapter, technical Acknowledgement

2015-10-11

Hi all, I have a SMTP --> XI --> Proxy Scenario. For the inbound message I get via SMTP, I'd like to send a technical acknowledgement back to the Sender (via SMTP, too). The acknowledgement has a specific message structure, for example it contains t

Sender Mail Adapter - S/MIME - How to use it?

2015-10-11

Hi guys, I am trying to figure out how to use the S/MIME security parameter of the Sender Mail Adapter in PI 7.1. Could anyone point me to some useful documentation/examples/blogs ? Or perhaps explain what steps are involved when configuring this par

Sender Mail adapter configuration with attachment

2015-10-11

Hi, I read the below blog regarding the mail adapter /people/michal.krawczyk2/blog/2005/12/18/xi-sender-mail-adapter--payloadswapbean--step-by-step I have the same requirement but the attachment file is not an XML, it is CSV file so in the module tab

Sender Mail Adapter with PayloadSwapBean

2015-10-11

Hello Experts! I have a Sender Mail Adapter receiving emails with attachments! I'm using PayloadSwapBean, because I have to manipulate (to do mapping) the XML attachment. Sender Mail Adapter Configuration: Default Interface Namespace = urn:mynamespac

Sender Mail Adapter Error: exception caught during processing mail message;

2015-10-11

HI , I am configuring mail to file scenario. Need to read mail content (no need to capture From,TO or Subject details) and create a file with the content in the mail. Need to read mails from microsoft outlook. Exchange server has been configured for

Sender Mail Adapter - default interface name

2015-10-11

Hi, I need to receive through one e-mail sender channel tree different kind of messages. In sender mail adapter I specify ecept other parameters "Default Interface Name". When I send a message with a same as defined in an interface the message i

Sender Mail Adapter issue

2015-10-11

Hi All, We are getting this error in Sender Mail adapter. "exception caught during processing mail message; java.net.ConnectException: A remote host refused an attempted connect operation" It is a (Lotus Notes) Mail to File scenario. Used POP3,

Sender  Mail Adapter - java.lang.NullPointerException in CC monitoring

2015-10-11

hi, I configured my Sender Mail Adapter correctly. I have the correct POP URL, authentication. I'm not using PayloadSwapBean right now. I can't get rid of the exception inside my Channel monitoring. exception caught during processing mail message; ja

How to determine the protocol to use in Sender mail Adapter ?

2015-10-11

Hi All Can i use my Microsoft Exhange Server address while configuring Sender Mail Adapter .? If yes , then which protocol i can use out of IMAP and POP ?.. How do i determine which protocol i should use to connect to my exchange server ? Thanks roha

Using header paramter SHeaderX-MS-HAS-ATTACH  in Sender mail adapter

2015-10-11

I am trying to check if an e-mail contains attachment in reciever determintion I set the Variable Header XHeaderName1 to be SHeaderX-MS-HAS-ATTACH in Sender mail adapter I added a condition in the receving determintation XHeaderName1 = yes I see the

Dynamic file name of the attachment in sender mail adapter

2015-10-11

Hi I have configured a sender mail adapter which receives some attachments. Right now the file name of the attachment is hardcoded to "MailAttachment-1" "MailAttachment-2" using the content-description from "AF_Modules/PayloadSwap

Error when using Variable Transport Binding in Sender Mail Adapter

2015-10-11

Hi, I am using the Sender Mail Adapter to receive an email, convert the attached tab delimited text file into xml and map it to an IDOC. I am using PayloadSwapBean and MessageTransformBean in order to do this, and this all works perfectly. I am now t

How to download / read  text attachment  in Sender Mail Adapter  IN XI

2015-10-11

Hi I would like to know how to download / read text attachment in sender mail Adapter & sent same attachment to target system using file adapter. Please help how to design / resolve this concept. Regards DSRI would like to know how to download / read