Html emails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Html emails

    Hi

    I am using the following code to send html emails via outlook.

    objOutlook = CreateObject("O utlook.Applicat ion")
    objOutlookMsg = objOutlook.Crea teItem(Outlook. OlItemType.olMa ilItem)
    fso = CreateObject("S cripting.FileSy stemObject")
    ts = fso.OpenTextFil e(m_objParentFo rm.txtHtml.Text .ToString, 1)
    eMessage = ts.ReadAll
    With objOutlookMsg
    eto = "Recepient@mydo mian.com"
    objOutlookRecip = .Recipients.Add (eto)
    objOutlookRecip .Type = Outlook.OlMailR ecipientType.ol To
    .Subject = "My Subject"
    .HTMLBody = eMessage
    .Send()
    End With
    objOutlook = Nothing

    The problem is that bodies of emails are coming out blank, where there
    should be html read from file. What am I doing wrong?

    Thanks

    Regards


  • Cor

    #2
    Re: Html emails

    Hi John,
    This is not VB.net code, it is VB scripting.
    Information about this, you can ask better in a scripting newsgroup.
    As far as I can see is the problem in this part of the code[color=blue]
    > fso = CreateObject("S cripting.FileSy stemObject")
    > ts = fso.OpenTextFil e(m_objParentFo rm.txtHtml.Text .ToString, 1)[/color]
    I thought that with this code alone, you don't read the file.

    I hope this helps a bit.
    Cor


    Comment

    • Fergus Cooney

      #3
      Re: Html emails

      Hi John,

      Some questions.

      Have you verified that you are opening your file correctly?
      Have you verified that you are reading your file successfully?
      Does the file contain valid HTML?
      If you assign a string of HTML, eg "<html><body>Pl ease work for
      me!!</body></html>", to the HTMLBody, does it accept it?

      Regards,
      Fergus


      Comment

      • John

        #4
        Re: Html emails

        Yes to all the questions. I placed a breakpoint and emessage value shows at
        each step when I bring the mouse over it. The file is read correctly into
        emessage, which is the most puzzling thing.

        Thanks

        Regards


        "Fergus Cooney" <filter-1@tesco.net> wrote in message
        news:%23JebGFAi DHA.2400@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > Hi John,
        >
        > Some questions.
        >
        > Have you verified that you are opening your file correctly?
        > Have you verified that you are reading your file successfully?
        > Does the file contain valid HTML?
        > If you assign a string of HTML, eg "<html><body>Pl ease work for
        > me!!</body></html>", to the HTMLBody, does it accept it?
        >
        > Regards,
        > Fergus
        >
        >[/color]


        Comment

        • John

          #5
          Re: Html emails

          Hi

          It seems to compile OK in vb.net. I am not too comfortable with substring so
          I still use left/right etc. Is there an example of html mailing from vb.net,
          using outlook, somewhere?

          Thanks

          Regards



          "Cor" <non@non.com> wrote in message
          news:3f7a8281$0 $2025$48b97d01@ reader21.wxs.nl ...[color=blue]
          > Hi John,
          > This is not VB.net code, it is VB scripting.
          > Information about this, you can ask better in a scripting newsgroup.
          > As far as I can see is the problem in this part of the code[color=green]
          > > fso = CreateObject("S cripting.FileSy stemObject")
          > > ts = fso.OpenTextFil e(m_objParentFo rm.txtHtml.Text .ToString, 1)[/color]
          > I thought that with this code alone, you don't read the file.
          >
          > I hope this helps a bit.
          > Cor
          >
          >[/color]


          Comment

          • Fergus Cooney

            #6
            Re: Html emails

            Hi John,

            If you post your actual code, ie something that I can run immediately,
            then I can try it out.

            Regards,
            Fergus


            Comment

            • John

              #7
              Re: Html emails


              Here it is;

              objOutlook = CreateObject("O utlook.Applicat ion")
              objOutlookMsg = objOutlook.Crea teItem(Outlook. OlItemType.olMa ilItem)
              fso = CreateObject("S cripting.FileSy stemObject")
              ts = fso.OpenTextFil e(m_objParentFo rm.txtHtml.Text .ToString, 1)
              eMessage = ts.ReadAll
              With objOutlookMsg
              eto = "Recepient@mydo mian.com"
              objOutlookRecip = .Recipients.Add (eto)
              objOutlookRecip .Type = Outlook.OlMailR ecipientType.ol To
              .Subject = "My Subject"
              .HTMLBody = eMessage
              .Send()
              End With
              objOutlook = Nothing

              Thanks

              Regards

              "Fergus Cooney" <filter-1@tesco.net> wrote in message
              news:utFnTsoiDH A.1508@TK2MSFTN GP10.phx.gbl...[color=blue]
              > Hi John,
              >
              > If you post your actual code, ie something that I can run immediately,
              > then I can try it out.
              >
              > Regards,
              > Fergus
              >
              >[/color]


              Comment

              • Fergus Cooney

                #8
                Re: Html emails

                Hi John,

                Lol. That's the same code as in your original post!!

                I tried it when you first posted it. Unfortunately it doesn't compile. At
                the least I would like a complete Sub/Function with all variables declared,
                etc. Then I'd have to build a test harness around it.

                What I was asking and hoping for is something that I can <run
                immediately>. A zip of a working project (complete with the correct
                references) that I can simply open and run.

                Want to give it another shot?

                Regards,
                Fergus


                Comment

                • Cor

                  #9
                  Re: Html emails

                  Hi John,
                  In addition to Fergus,
                  This is the part in Fergus message I am also specialy curious for[color=blue]
                  > all variables declared,[/color]
                  Cor



                  Comment

                  Working...