ASPMail - Format email in HTML which has ATTACHMENT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yash777
    New Member
    • Mar 2008
    • 20

    ASPMail - Format email in HTML which has ATTACHMENT

    hello all,

    how can we send an html formatted email which has word ATTACHMENT ???

    (is it possible)
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Yash,

    Use the following code snippet to help you:

    Code:
     
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="mymail@mydomain.com"
    myMail.To="yourmail@mydomain.com"
    myMail.CreateMHTMLBody "[url="http://www.w3schools.com/asp/"]http://www.w3schools.com/asp/[/url]" 
    myMail.AddAttachment "C:\AttachmentFile.txt"
    myMail.Send
    set myMail=nothing
    Hope this helps,

    Dr B

    Comment

    • yash777
      New Member
      • Mar 2008
      • 20

      #3
      hello DR.B,

      Actually i m requesting entries from a form and then sending those form elements in formated html (within same page)

      following is sample of my code:

      Code:
      jobcode=TRIM(Request.Form("jobcode"))
      jobcategory=TRIM(Request.Form("jobid"))
      name=TRIM(Request.Form("f_name"))&" "&TRIM(Request.Form("m_name"))&" "&TRIM(Request.Form("l_name"))
      sex=TRIM(Request.Form("gender"))
      M_status=TRIM(Request.Form("optMarital"))
      
      strbody = "<font face='verdana' size=2>"
      strbody = strbody & "<BR><B>Job Code</B> : "&jobcode&" <br>"
      strbody = strbody & "<BR><B>Job Category</B> : "&jobcategory&" <br>"
      strbody = strbody & "<BR><B>Name</B> : "&name&" <br>"
      strbody = strbody & "<BR><B>Gender</B> : "&sex&" <br>"
      sending the above strBody as body

      Code:
      Mailer.BodyText = strBody
      Mailer.AddAttachment(...........)
      and i m using SMTPsvg mailer.

      can it be done within the same page.

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        I don't see why not. You could probably do something like

        Code:
         Mailer.ContentType = "text/html" 
        Mailer.BodyText = strBody
        Mailer.AddAttachment "AttachmentFile.txt"
        Give it a try and let me know how it goes,

        Dr B

        Comment

        • yash777
          New Member
          • Mar 2008
          • 20

          #5
          hello dr.B,

          yes i did the same but when i check the mail it just write that HTML code also,

          i read somewere that Mailer.ContentT ype="text/html" gets omitted when u use attachment.

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            I've just had a quick google and that seems to be the case, certainly with some versions of ASPMail. There is a possible fix here which might help you.

            Otherwise have you considered using CDOSYS instead?

            Let me know if that link helps you,

            Dr B

            Comment

            • yash777
              New Member
              • Mar 2008
              • 20

              #7
              NO, it's not helpful.

              Any other way to do this????

              don't have any idea about CDOSYS......... ...

              How can we do this using CDOSYS ??

              Comment

              • DrBunchman
                Recognized Expert Contributor
                • Jan 2008
                • 979

                #8
                CDOSYS is a mail object just like ASPMail.

                Try the code below and let me know if it works.
                Code:
                 Set myMail=CreateObject("CDO.Message") 
                myMail.Subject="Sending email with CDO"
                myMail.From=[email="mymail@mydomain.com"]mymail@mydomain.com[/email]
                myMail.To=[email="yourmail@mydomain.com"]yourmail@mydomain.com[/email]
                myMail.HTMLBody = strBody
                myMail.AddAttachment "C:\AttachmentFile.txt"
                myMail.Send
                set myMail=nothing
                Dr B

                Comment

                • yash777
                  New Member
                  • Mar 2008
                  • 20

                  #9
                  thank u for ur reply,

                  actually i dont know all properties of CDOSYS like

                  Code:
                  Mailer.FromName = 
                  Mailer.FromAddress = 
                  Mailer.RemoteHost =  
                  Mailer.ReturnReceipt = true
                  Mailer.ConfirmRead = false
                  Mailer.Priority = 0
                  Mailer.Subject = subject
                  Mailer.ContentType = "text/html"
                  Mailer.BodyText = strBody
                  Mailer.ClearRecipients		
                  Mailer.AddRecipient 
                  Mailer.AddRecipient 
                  Mailer.AddAttachment
                  Mailer.SendMail
                  i will google it a bit and then let u know whether it is working or not.

                  and also my office timing is over.

                  SO.. thanx for ur support, hope will clear this tomorrow.

                  thanx again.

                  Comment

                  • DrBunchman
                    Recognized Expert Contributor
                    • Jan 2008
                    • 979

                    #10
                    No problem, check out w3Schools for some of the properties but there are loads of resources out there.

                    Dr B

                    Comment

                    • yash777
                      New Member
                      • Mar 2008
                      • 20

                      #11
                      hello DR.B,

                      thanx a lot for ur support.

                      i did it with CDOSYS, it's working fine for me.

                      thanx again..

                      keep replying.

                      Comment

                      • DrBunchman
                        Recognized Expert Contributor
                        • Jan 2008
                        • 979

                        #12
                        Excellent Yash! Glad you got it sorted out.

                        Dr B

                        Comment

                        Working...