cancel
Showing results for 
Search instead for 
Did you mean: 

Mail being sent to wrong email id in smartform

Former Member
0 Kudos

Hi,

I have to send a smartform through email as PDF attachment.The mail should be sent to the person whose mail id is present in vd03 transaction.If there is no mail id then the attachment has to be sent through telefax.

I have given the code like this to pick the email address.

SELECT SINGLE vbeln

FROM vttp

INTO lv_vbeln

WHERE tknum = vttkvb-tknum.

IF sy-subrc = 0.

SELECT SINGLE kunnr

INTO lv_kunnr

FROM vbpa

WHERE vbeln = lv_vbeln

AND parvw EQ 'AG'.

IF sy-subrc = 0.

SELECT SINGLE adrnr

FROM vbpa

INTO lv_adrnr

WHERE vbeln = lv_vbeln

AND kunnr = lv_kunnr

AND posnr = 0

AND parvw = 'AG'.

IF sy-subrc EQ 0.

CLEAR lv_addr.

SELECT smtp_addr

FROM adr6

UP TO 1 ROWS

INTO lv_addr

WHERE addrnumber = lv_adrnr.

ENDSELECT.

There is no email address in vdo3 transaction.

But still it is sending the mail to wrong email id.

When I checked in vbpa table with the delivery number and customer number,i am able to find the email id of the person to which the email is being sent.

But the mail should only be sent to the person whose mail id is present in vd03 transaction.How can I do this?

Regards,

Hema

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

Check the email address from

SELECT smtp_addr

FROM adr6

UP TO 1 ROWS

INTO lv_addr

WHERE addrnumber = lv_adrnr.

ENDSELECT.

debug it

it may be different

Regards

Shiva

Former Member
0 Kudos

Hi,

In debugging mode,it is picking the email id for variable lv_adrnr.But,this is wrong. This mail id is not present in vdo3 transaction.

It should send a mail only to the person whose mail id is present in vdo3 transaction.If the mail id is not present then the attachment should be sent through fax.