Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

sending External mail

Former Member
0 Kudos
120

Hi, i have a couple of reports that send notifications via e-mail, and they are working fine, except that the e-mails only get to the SAP inbox of the users... I want the e-mails to go outside of SAP into our exchange server.

Is there a parameter that needs to be set when calling the function that sends the e-mail from ABAP, or is it a Basis problem?

If you need any more details, please tell me.

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos
85

Hi

Try below code it worked for me..It sends mail to external mail IDs as well..

Hope it work for you.!!

&----


*& Report ZTUSM_SEND_MAIL *

*& *

&----


*& *

*& *

&----


REPORT ZTUSM_SEND_MAIL.

DATA: att_size TYPE i, " att Size

att_itab_size TYPE i, " Attachment size

mailtxt_size TYPE i. " Text in mail size

DATA:

it_mailpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " Dist details

it_mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE," Header data

it_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE, " Rec List

it_mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Mail Text

it_att_data LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Attachment data

it_doc_att LIKE sodocchgi1. " Attri of new doc

  • Text in the mail.

it_mailtxt-line =

'<BODY BGCOLOR="#FFFFCC">' &

' This is a test mail, Line Number--1'

.

APPEND it_mailtxt.

it_mailtxt-line = ' This is a test mail, Line Number--2' &

' This is a test mail, Line Number--2'.

APPEND it_mailtxt.

it_mailtxt-line = 'This is a test mail, Line Number--3' &

' This is a test mail, Line Number--3' &

' This is a test mail, Line Number--3'.

APPEND it_mailtxt.

DESCRIBE TABLE it_mailtxt LINES mailtxt_size.

  • Create the att File

concatenate 'Attachment Line Number 1' space into

it_att_data-line.

APPEND it_att_data.

concatenate 'Attachment Line Number 2' space into

it_att_data-line.

APPEND it_att_data.

concatenate 'Attachment Line Number 3' space into

it_att_data-line.

APPEND it_att_data.

DESCRIBE TABLE it_att_data LINES att_itab_size.

  • Attributes of new doc

CONCATENATE 'Attach' space 'mail'

INTO it_doc_att-obj_descr SEPARATED BY space.

it_doc_att-sensitivty = 'F'.

it_doc_att-doc_size = mailtxt_size * 255.

  • Create Pack to text in mail body.

it_mailpack-transf_bin = space.

it_mailpack-head_start = 1.

it_mailpack-head_num = 0.

it_mailpack-body_start = 1.

it_mailpack-body_num = mailtxt_size.

it_mailpack-doc_type = 'HTM'.

APPEND it_mailpack.

  • Create Pack for Attach.

it_mailpack-transf_bin = 'X'.

it_mailpack-head_start = 1.

it_mailpack-head_num = 1.

it_mailpack-body_start = 1.

it_mailpack-body_num = att_itab_size.

it_mailpack-doc_type = 'HTM'.

CONCATENATE 'My' space 'Attachment' INTO it_mailpack-obj_descr.

it_mailpack-doc_size = att_itab_size * 255.

APPEND it_mailpack.

it_reclist-receiver = 'tushar.mundlik@gmail.com'.

it_reclist-express = 'X'.

it_reclist-rec_type = 'U'.

*it_reclist-notif_del = 'X'. " request delivery notification

APPEND it_reclist.

  • Call FM to send email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = it_doc_att

put_in_outbox = 'X'

TABLES

packing_list = it_mailpack

object_header = it_mailhead

contents_txt = it_mailtxt

contents_bin = it_att_data

receivers = it_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Mark if helpful

Regards

6 REPLIES 6

Former Member
0 Kudos
85

Hi,

These are the FM for sending external email :-

SO_DOCUMENT_SEND_API1

SAPoffice: Send new document with attachments via RFC

SO_NEW_DOCUMENT_ATT_SEND_API1

(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)

SAPoffice: Send new document with attachments via RFC

Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.

SO_NEW_DOCUMENT_SEND_API1

SAPoffice: Send new document

For program click the following link:

http://www.sap-img.com/fu016.htm

Regards,

Bhaskar

0 Kudos
85

I've read the documentation for the FM I'm using: SO_NEW_DOCUMENT_ATT_SEND_API1

and it seems i'm doing it right...

I retrieve the users e-mail address and add it to the recievers list, with rec_type set to U.

The e-mail does get sent, but only to the user's inbox in the Business Workplace, and I need it to go all the way to his Outlook inbox.

If i go to the inbox and click the Send button, I type my address from the exchange server and I do recieve it in my Outlook inbox... why isn't this happening automatically?

Former Member
0 Kudos
86

Hi

Try below code it worked for me..It sends mail to external mail IDs as well..

Hope it work for you.!!

&----


*& Report ZTUSM_SEND_MAIL *

*& *

&----


*& *

*& *

&----


REPORT ZTUSM_SEND_MAIL.

DATA: att_size TYPE i, " att Size

att_itab_size TYPE i, " Attachment size

mailtxt_size TYPE i. " Text in mail size

DATA:

it_mailpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " Dist details

it_mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE," Header data

it_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE, " Rec List

it_mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Mail Text

it_att_data LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Attachment data

it_doc_att LIKE sodocchgi1. " Attri of new doc

  • Text in the mail.

it_mailtxt-line =

'<BODY BGCOLOR="#FFFFCC">' &

' This is a test mail, Line Number--1'

.

APPEND it_mailtxt.

it_mailtxt-line = ' This is a test mail, Line Number--2' &

' This is a test mail, Line Number--2'.

APPEND it_mailtxt.

it_mailtxt-line = 'This is a test mail, Line Number--3' &

' This is a test mail, Line Number--3' &

' This is a test mail, Line Number--3'.

APPEND it_mailtxt.

DESCRIBE TABLE it_mailtxt LINES mailtxt_size.

  • Create the att File

concatenate 'Attachment Line Number 1' space into

it_att_data-line.

APPEND it_att_data.

concatenate 'Attachment Line Number 2' space into

it_att_data-line.

APPEND it_att_data.

concatenate 'Attachment Line Number 3' space into

it_att_data-line.

APPEND it_att_data.

DESCRIBE TABLE it_att_data LINES att_itab_size.

  • Attributes of new doc

CONCATENATE 'Attach' space 'mail'

INTO it_doc_att-obj_descr SEPARATED BY space.

it_doc_att-sensitivty = 'F'.

it_doc_att-doc_size = mailtxt_size * 255.

  • Create Pack to text in mail body.

it_mailpack-transf_bin = space.

it_mailpack-head_start = 1.

it_mailpack-head_num = 0.

it_mailpack-body_start = 1.

it_mailpack-body_num = mailtxt_size.

it_mailpack-doc_type = 'HTM'.

APPEND it_mailpack.

  • Create Pack for Attach.

it_mailpack-transf_bin = 'X'.

it_mailpack-head_start = 1.

it_mailpack-head_num = 1.

it_mailpack-body_start = 1.

it_mailpack-body_num = att_itab_size.

it_mailpack-doc_type = 'HTM'.

CONCATENATE 'My' space 'Attachment' INTO it_mailpack-obj_descr.

it_mailpack-doc_size = att_itab_size * 255.

APPEND it_mailpack.

it_reclist-receiver = 'tushar.mundlik@gmail.com'.

it_reclist-express = 'X'.

it_reclist-rec_type = 'U'.

*it_reclist-notif_del = 'X'. " request delivery notification

APPEND it_reclist.

  • Call FM to send email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = it_doc_att

put_in_outbox = 'X'

TABLES

packing_list = it_mailpack

object_header = it_mailhead

contents_txt = it_mailtxt

contents_bin = it_att_data

receivers = it_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Mark if helpful

Regards

0 Kudos
85

Hey it did work... now let me compare it with my code and see if it works then... thanks

0 Kudos
85

Hi Good

Please mark question as answered and reward points if helpful..

Regards

Tushar

Former Member
0 Kudos
85

Let me know if any inputs needed ..