Application Development and Automation 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: 
Read only

send PDF attachment through mail

Former Member
0 Likes
757

i have one PDF document on my desktop, i want to sent that PDF as attachment to mail through SAP.

can anybody have idea how to get?

i have one PDF document on my desktop, i want to sent that PDF as attachment to mail through SAP.

can anybody have idea how to get?

4 REPLIES 4
Read only

Former Member
0 Likes
635

Hi

There are lot function module to attach the file as mail.

One of the example is smpt_sendmail

regards,

Naresh

Read only

0 Likes
635

This FM does not exist in 4.7 it seems.

Read only

0 Likes
635

Hi,

you can use FM 'SO_DOCUMENT_REPOSITORY_MANAGER' with methods in the following order

ATTCREATEFROMPC

SAVE

SEND.

Hope this helps you.

Read only

Former Member
0 Likes
635

i also had the same requirement... the following code is to attach a pdf file from PC. 'PDF' has been hard coded. to attach a text file change it to 'TXT'.

&----


*& Report Y_FILE_FROM_PC

*&

&----


*&

*&

&----


REPORT y_file_from_pc.

  • * This program will allowed you to send email with attachment.

  • First, specify the attachment file from your local hardisk and execute.

  • Next, specify the sender email address and click the send button.

DATA: method1 LIKE sy-ucomm,

g_user LIKE soudnamei1,

g_user_data LIKE soudatai1,

g_owner LIKE soud-usrnam,

g_receipients LIKE soos1 OCCURS 0 WITH HEADER LINE,

g_document LIKE sood4 ,

g_header LIKE sood2,

g_folmam LIKE sofm2,

g_objcnt LIKE soli OCCURS 0 WITH HEADER LINE,

g_objhead LIKE soli OCCURS 0 WITH HEADER LINE,

g_objpara LIKE selc OCCURS 0 WITH HEADER LINE,

g_objparb LIKE soop1 OCCURS 0 WITH HEADER LINE,

g_attachments LIKE sood5 OCCURS 0 WITH HEADER LINE,

g_references LIKE soxrl OCCURS 0 WITH HEADER LINE,

g_authority LIKE sofa-usracc,

g_ref_document LIKE sood4,

g_new_parent LIKE soodk.

DATA: BEGIN OF g_files OCCURS 10 ,

text(4096) TYPE c,

END OF g_files.

DATA : fold_number(12) TYPE c,

fold_yr(2) TYPE c, fold_type(3) TYPE c.

PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\debugger.PDF'.

  • can me any file fromyour pc ....either xls or word or ppt etc ...

g_user-sapname = sy-uname.

CALL FUNCTION 'SO_USER_READ_API1'

EXPORTING user = g_user

  • prepare_for_folder_access = ' '

IMPORTING

user_data = g_user_data

*EXCEPTIONS

  • user_not_exist = 1

  • parameter_error = 2

  • x_error = 3

  • OTHERS = 4

.

IF sy-subrc NE 0.

  • message id sy-msgid type sy-msgty number sy-msgno

  • with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

fold_type = g_user_data-outboxfol+0(3).

fold_yr = g_user_data-outboxfol+3(2).

fold_number = g_user_data-outboxfol+5(12).

CLEAR g_files.

REFRESH : g_objcnt, g_objhead, g_objpara, g_objparb, g_receipients, g_attachments, g_references, g_files.

method1 = 'SAVE'.

g_document-foltp = fold_type.

g_document-folyr = fold_yr.

g_document-folno = fold_number.

g_document-objtp = g_user_data-object_typ.

*g_document-objyr = '27'.

*g_document-objno = '000000002365'.

*g_document-objnam = 'MESSAGE'.

g_document-objdes = 'attach file from pc'.

g_document-folrg = 'O'.

*g_document-okcode = 'CHNG'.

g_document-objlen = '0'.

g_document-file_ext = 'PDF'.

g_header-objdes = 'attach file from pc'.

g_header-file_ext = 'PDF'.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING method = method1

office_user = sy-uname

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header

  • folmem_data =

  • receive_data =

.

  • file from the pc to send..

method1 = 'ATTCREATEFROMPC'.

g_files-text = ws_file.

APPEND g_files.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header.

method1 = 'SEND'.

g_receipients-recnam = 'ABAP'.

g_receipients-recesc = 'B'.

g_receipients-sndex = 'X'.

APPEND g_receipients.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header.

hope this helps!