ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

HTML Emails and Images....How to include..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTML Emails and Images....How to include..

    Hi!

    I'm back .... Okay I got my HTML issue resolved and working. I took the easy way and I created a CL and I pass the values to the CL and I use the SNDHTMLEML command that was written by David Faust that I found on the internet and I am using that. Works great once I got help in figuring out what I was doing wrong with the HTML code.

    On to my next issue ... I want to make the HTML email that I am sending to our clients to look polished - so I want to include the company logo. I just have to include that as part of the HTML code correct and it should work - right? I was just reading an article on the web and it talked about the image having to be on the internet and my mind stopped and said wait a minute I remember something about that from the HTML classes I took years ago.

    So an inquirying mind wants to know ... do I need to worry about that?

    Thanks!
    Roxann

  • #2
    Re: HTML Emails and Images....How to include..

    html just points to stuff. so look at a page and see that it points to the image on the server.

    When you get an image with images, exchange pops a button to see if you want to download the images. To stay with Html, you have to do it this way.


    You could create a PDF that has the image in it.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: HTML Emails and Images....How to include..

      If you want to send the images inside the e-mail itself, then you need more than just plain HTML. You need to creae a multi-part MIME message using the "multipart/related" content type. I'm assuming that a command named SNDHTMLEML doesn't do that, but I could be wrong...

      The other approach is to have HTML with http:// URLs for the images. This will allow the images to be downloaded via a web server, but most E-mail clients will not show the images by default in that case, you'll have to tell it to download them explicitly, or add the sender to a "safe senders" list. Otherwise, there are privacy concerns with this approach.

      Comment


      • #4
        Re: HTML Emails and Images....How to include..

        @Scott - Yes, I am trying to include the image (the company logo) in the email. Our web programmer gave me the HTML source for retrieving the company logo from our website and I put that in my code but I didn't get the image (see below). I checked the SNDHTMLEML program and it does include the multipart/related, so I am scratching my head now.

        PHP Code:
        header = %trim(header) +'Date: ' maildate CONST_LF           
                 
        +'Subject: ' parmSubject CONST_LF                   
                 
        +'MIME-Version: 1.0' CONST_LF                         
                 
        +'Content-Type: multipart/related; boundary="MSG_PART"' 
                 
        CONST_LF CONST_LF '--MSG_PART' CONST_LF         
                 
        +'Content-Type: text/html' CONST_LF                   
                 
        +'Content-Disposition: inline;' CONST_LF CONST_LF   
                 
        CONST_LF
        Here's a picture of the email:
        Click image for larger version

Name:	Example HTML Email with logo.jpg
Views:	1
Size:	32.5 KB
ID:	126693

        Am I perhaps doing something wrong?

        @DeadMan - you remember how Kale wanted to send our clients an email with a link to the company website when their billing was ready? That's what I am working on right now - from the FourSoft side - for the US side of the business. When we get it figured out, we're going to add same processing to Canada side. Only changes since you left - we're up and running 45% of the US clients on FourSoft now.

        Basically - I didn't know if I wanted to include an image in the email if I needed to include some special wrappers or anything.

        I've included a PDF of the SNDHTMLEML code so you can tell me if it's missing something .... I haven't a clue. I'm just trying to satisfy the CEO's request for an automated email to our clients when their billing is ready...
        Attached Files

        Comment


        • #5
          Re: HTML Emails and Images....How to include..

          It looks like the image is in the email but not being downloaded - it is usually an option in your email client whether to automatically download pictures. Try right clicking the image area and select 'Download image' or similar if it shows on the menu.

          Comment


          • #6
            Re: HTML Emails and Images....How to include..

            @ScottM - I right clicked and selected show image and the image appeared. So my next question is -- is there code that I need to include so that it is automatically opened?

            Comment


            • #7
              Re: HTML Emails and Images....How to include..

              As far as I know that is an option at the client only, you can't override it.

              Comment


              • #8
                Re: HTML Emails and Images....How to include..

                Hey Rox, It is a client side only. Nothing you can do.
                Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                Comment


                • #9
                  Re: HTML Emails and Images....How to include..

                  The only way to make it show automatically is to include the image in the e-mail rather than linking to it on the web. Again, as I said earlier, this is a privacy concern. If an e-mail sender could just turn it off, that would enable those who would abuse this feature (such as viruses or spammers) to turn it off, too... and that defeats the purpose altogether.

                  The program you're using (SNDHTMLEML) does not look like it has the capability to embed images inside the html document.

                  One solution is to code your own e-mail using the multipart/related MIME type and with multiple parts, one for the HTML document, one for the image, and another one for each additional image. You could potentially modify SNDHTMLEML to do this.

                  Comment


                  • #10
                    Re: HTML Emails and Images....How to include..

                    Thank you all for your responses. I get it ... its like in Lotus when I get emails from vendors and I have the button at the top that says "Show Images" and I have to click on it to get the images to appear. Now to find out what the higher powers want to do...

                    Comment


                    • #11
                      Re: HTML Emails and Images....How to include..

                      I could code up an example of how to send an e-mail with the images included so you don't have this problem, but I would not be able to use the SNDHTMLEML command that you're using because it doesn't support this (though, I could modify it to support this...)

                      Unfortunately, I just don't have time right now, too much going on. But, if I can get to it later, would that be useful?

                      Comment


                      • #12
                        Re: HTML Emails and Images....How to include..

                        @Scott -- Sorry I haven't been in touch sooner... I've been out of the office for the last three days. If you could code up an example that would be most appreciated and would be quite useful .... and you can do it when you have time. The higher ups have all decided that what I have is acceptable for now, and when time permits later on I can revisit and make it nicer.

                        Thank you so much for the offer...

                        Roxann

                        Comment


                        • #13
                          Re: HTML Emails and Images....How to include..

                          NYCountryGal, you previously said you have GumboMail, and I think it might be able to do what you're requesting with *TEXTHTML on the OBJ keyword of GSENDMAIL if I'm understanding the manual correctly:
                          Objects (OBJ)
                          Specifies the path name of the object to send. A maximum of 64 path names can be specified.
                          For more information on specifying path names, see Programming > Control language > CL concepts > IBM i
                          objects > Object naming rules topic in the IBM i Information Center at http://publib.boulder.ibm.com/iseries/.
                          CHAR(5000)
                          Single values
                          *NONE No objects are sent.
                          Element 1: Name
                          path-name Specify an object path name.
                          Element 2: Send as
                          *ATTACH Send the object as an attached file using MIME and specifying "application/octet-stream".
                          *TEXTPLAIN Copy the object into the body of the mail message specifying content type text/plain. The CCSID of the file must
                          match the value specified for CHRENC().
                          Chapter 6 Commands 47
                          Note: Some servers disregard this request and form an attachment from the message in all cases. Some servers disregard
                          this request for the second and subsequent body parts. If this is the case, try MSG(*NONE).
                          *TEXTHTML Copy the object into the body of the mail message specifying content type text/html. The CCSID of the file must
                          match the value specified for CHRENC().
                          Note: Some servers disregard this request and form an attachment from the message in all cases. Some servers disregard
                          this request for the second and subsequent body parts. If this is the case, try MSG(*NONE).
                          *ATTACHPDF Send the object as an attached file using MIME and specifying "application/pdf". Use this value if the attached file
                          contains Adobe's Portable Document Format (pdf) data.
                          *ATTACHPS Send the object as an attached file using MIME and specifying "application/postscript". Use this value if the
                          attached file contains postscript data.
                          *NOTE Same as *TEXTPLAIN which is preferred.
                          Element 3: Multipart/alternative group
                          *NONE The object is not a member of a "multipart/alternative" group.
                          1-9 Specify a group number for forming "multipart/alternative" groups. All objects with the same group number are
                          members of a "multipart/alternative" in the generated email.
                          Might be worth playing with it to possibly save you (and Scott) a bunch of custom work.
                          Last edited by Viking; August 13, 2013, 04:39 PM.

                          Comment


                          • #14
                            Re: HTML Emails and Images....How to include..

                            @Viking - I agree with you - it looks like GumboMail can do this BUT .... we are two releases behind - so I don't have that available to me right now, and in order to get it available I need to install. Problem is we don't have a test box and my manager is as uneasy about installing the two releases directly to production as I am. I had an idea last night on the way home -- if I can install to a test library (I would need to create and get it to the same level before continuing) I might be able to get these on and do some testing. I need to talk to my manager but I am thinking this is an avenue worth investigating.

                            On a different note but same process -- since I am using the QMSF job -- how would I monitor this for issues? We need to know that the emails were sent to our clients and if there is a problem we need to know - IMMEDIATELY. Anyone have any ideas or suggestions? I'm not finding a whole lot on QMSF monitoring and so I am thinking I will need to create a process to monitor myself.

                            Comment


                            • #15
                              Re: HTML Emails and Images....How to include..

                              Hey, since you are using the beast to just pass through the email to the email server you cant use the beast to tell you. The email server knows if it was delivered or not.

                              You could parse data from the email server to see if the message was delivered or not. This would have to be a separate job as the delivery may take minutes to deliver. You would have to make sure that the combination of the sender email and recipient email are unique, IE not used by anybody else in the company.

                              If you used the beast as a smtp server then you could use some APIs to get the data.
                              Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                              Comment

                              Working...
                              X