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: 

Create hotspot in e-mail body text

Former Member
0 Kudos

Hello gurus!

I've been asked to create an e-mail which contains a hotspot linking customers to our website which contains the invoice, job pics, etc. Since the target page is a login with parameters, the url will contain these, and we do just want to print the entire url (this works though), but rather display "Click here to see your invoice". Is there any way to create a hotspot in the text (a.k.a. body) of an e-mail.

I have already tried adding html tags and changing the doc_type to HTML, but a bunch of garbage prints at the top of the e-mail and the hyperlink doesn't work (the link is there, but it doesn't point to the specified href.)

Just FYI - I have no problems with sending an e-mail, adding the hotspot is the issue.

If possible, I'd like to NOT have to create a smartform. Can anyone give me any suggestions?

Thanks in advance!

Lisa

P.S. - We're using mySAP ERP 2004.

10 REPLIES 10

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yep, I've done this before. You can just put HTML in the body, make sure that the doc_type = 'HTM', not 'HTML'.

Regards,

Rich Heilman

Former Member
0 Kudos

Rich,

When I try that, the To: and Subject: are blank...they've moved to the body of the e-mail, and the hyperlink appears, but the target is "3d" instead of http://www.centimark.com, even though the website was entered as <a href = "http://www.centimark.com">. Any ideas?

PS - I had also looked at an earlier reply of yours, and copied it, but it didn't do the trick either..

Lisa

0 Kudos

Please copy and run this code, please make sure to put your email address as a reciever. Does this not give you what you want?




report zrich_0002.

data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  perform build_text_message.
  perform build_receivers.
  perform send_mail_nodialog..

************************************************************************
*      Form  BUILD_TEXT_MESSAGE
************************************************************************
form build_text_message.


  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.


  mailtxt  = '<html>'.
  append mailtxt.
  mailtxt  = '<body>'.
  append mailtxt.

<b>  mailtxt = '<a href="http:\www.sap.com" target="_blank">' .
  append mailtxt.
  mailtxt = 'this link will take you to SAP.com</a>' .
  append mailtxt.</b>

  mailtxt  = '</body>'.
  append mailtxt.
  mailtxt  = '</html>'.
  append mailtxt.

endform.

************************************************************************
*      Form  BUILD_RECEIVERS
************************************************************************
form build_receivers.

<b>  mailrec-receiver = 'you@yourcompany.com'.
  mailrec-rec_type  = 'U'.
  append mailrec.</b>

endform.

************************************************************************
*      Form  SEND_MAIL_NODIALOG
************************************************************************
form send_mail_nodialog.

  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
<b>            document_type              = 'HTM'</b>
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       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.

endform.

Regards,

Rich Heilman

Former Member
0 Kudos

Rich,

We copied your program and tried to run. Here's what we're getting in the <u>body</u> of the e-mail:

To: niranjan.yerraguntla@centimark.com From: "Niranjan Yerraguntla" Message-Id: Mime-Version: 1.0 X-Mailer: SAP R/3 Internet Mail Gateway 4.6D13 Subject: Test Subject Content-Type: TEXT/HTML; Charset="ISO-8859-1" Content-Transfer-Encoding: QUOTED-PRINTABLE = = = =20=

= = = =20= = = = =20= this link will take you to SAP.com = = = =20=

= = = =20=

=

In Lotus Notes and hotmail, the sender appears as yourname@yourhost.com. The subject is blank (not TEST).

Also, the hotspot (it does appear blue & underlined) takes you to the url 3D"http://www.sap.com"/ which (of course) doesn't work.

Upon looking into the SCOT settings a little bit further, we noticed that 1) there is no conversion choice for RAW text to HTML 2) no matter what settings we give in ABAP code or in SCOT settings, the SAPOffice Object ID is always RAW31.....

Can you think of any settings that may be causing this?

Thanks for all your help.

Lisa

0 Kudos

Not sure about the settings. THis program works really good in my system. Are you sure that your lotus notes mail server is configured to allow HTML content when sending.

Regards,

Rich Heilman

Former Member
0 Kudos

Rich,

I thought that might be the issue, too, since Lotus is weird about things like that...but I got exactly the same e-mail contents sending to a hotmail account.

My manager and I both looked at the SCOT settings to see if there was something obviously wrong, we tried a few things but nothing seemed to help. We're thinking it may be something in the outgoing mail setup.

I'm going to try the SmartForms route, to see if I can get the link to work there....plus I'm sure our customers will love the razzle dazzle the we can add to a smartform e-mail.

Thanks again for all of your help and the quick responses!!

Lisa

0 Kudos

That's what I meant, the server which does the actual sending of the mail could be stripping some of the HTML off before sending to various accounts.

Regards,

Rich Heilman

Former Member
0 Kudos

Ok, here's the solution. First of all, we're using a newer FM for the sending of the mail, called SO_NEW_DOCUMENT_ATT_SEND_API1....when we were setting up the objpack information, we needed to add this code:

objpack-transf_bin = 'X'.

the code now looks like this:

  • Creation of the document to be sent.

doc_chng-obj_name = 'SENDFILE'.

  • Subject of email - max 50 characters.

doc_chng-obj_descr = 'Test email'.

  • Mail body

append 'Message content' to objbin.

APPEND '<p><b>How is this for sending HTML E-mail from SAP?</b>'

TO objbin.

APPEND '<p>' TO objbin.

APPEND '<A HREF="HTTP://WWW.centimark.COM">' TO objbin.

APPEND 'Click to visit' TO objbin.

APPEND '</A>' TO objbin.

APPEND '<p>' TO objbin.

REFRESH reclist. CLEAR reclist.

reclist-receiver = person@company.com'.

reclist-rec_type = 'U'.

reclist-express = 'X'.

APPEND reclist. CLEAR reclist.

CLEAR tab_lines.

DESCRIBE TABLE objbin LINES tab_lines.

READ TABLE objbin INDEX tab_lines.

doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).

  • Creation of the entry for the compressed document.

REFRESH: objpack. CLEAR objpack.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

<b>objpack-transf_bin = 'X'.</b>

objpack-doc_type = 'HTM'.

APPEND objpack. CLEAR objpack.

  • Sending the document.

objtxt-line = 'test email'.

append objtxt.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = space

commit_work = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = objpack

object_header = objhead

contents_bin = objbin

contents_txt = objtxt

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = 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.

0 Kudos

Its not really newer, its just allowing for attachments. This could have been helpful information in helping to solve your problem. Anyway, glad that its working.

Regards,

Rich Heilman

Former Member
0 Kudos

Rich,

When we were testing yesterday, we were using the FM you had used (actually I started by just using your code verbatim). After we had similar display issues sending the HTML e-mail using smartforms, we took a closer look at what the settings were in the "sending" FM. So, we experimented using the FM we were more familiar with, and got it working.

Thanks again for all of your assistance!

Lisa