469,323 Members | 1,517 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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)
Jun 12 '08 #1
11 2831
979 Expert 512MB
Hi Yash,

Use the following code snippet to help you:

Expand|Select|Wrap|Line Numbers
  2. Set myMail=CreateObject("CDO.Message")
  3. myMail.Subject="Sending email with CDO"
  4. myMail.From="mymail@mydomain.com"
  5. myMail.To="yourmail@mydomain.com"
  6. myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" 
  7. myMail.AddAttachment "C:\AttachmentFile.txt"
  8. myMail.Send
  9. set myMail=nothing
Hope this helps,

Dr B
Jun 12 '08 #2
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:

Expand|Select|Wrap|Line Numbers
  1. jobcode=TRIM(Request.Form("jobcode"))
  2. jobcategory=TRIM(Request.Form("jobid"))
  3. name=TRIM(Request.Form("f_name"))&" "&TRIM(Request.Form("m_name"))&" "&TRIM(Request.Form("l_name"))
  4. sex=TRIM(Request.Form("gender"))
  5. M_status=TRIM(Request.Form("optMarital"))
  7. strbody = "<font face='verdana' size=2>"
  8. strbody = strbody & "<BR><B>Job Code</B> : "&jobcode&" <br>"
  9. strbody = strbody & "<BR><B>Job Category</B> : "&jobcategory&" <br>"
  10. strbody = strbody & "<BR><B>Name</B> : "&name&" <br>"
  11. strbody = strbody & "<BR><B>Gender</B> : "&sex&" <br>"
sending the above strBody as body

Expand|Select|Wrap|Line Numbers
  1. Mailer.BodyText = strBody
  2. Mailer.AddAttachment(...........)
and i m using SMTPsvg mailer.

can it be done within the same page.
Jun 12 '08 #3
979 Expert 512MB
I don't see why not. You could probably do something like

Expand|Select|Wrap|Line Numbers
  1.  Mailer.ContentType = "text/html" 
  2. Mailer.BodyText = strBody
  3. Mailer.AddAttachment "AttachmentFile.txt"
Give it a try and let me know how it goes,

Dr B
Jun 12 '08 #4
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.ContentType="text/html" gets omitted when u use attachment.
Jun 12 '08 #5
979 Expert 512MB
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
Jun 12 '08 #6
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 ??
Jun 12 '08 #7
979 Expert 512MB
CDOSYS is a mail object just like ASPMail.

Try the code below and let me know if it works.
Expand|Select|Wrap|Line Numbers
  1.  Set myMail=CreateObject("CDO.Message") 
  2. myMail.Subject="Sending email with CDO"
  3. myMail.From=mymail@mydomain.com
  4. myMail.To=yourmail@mydomain.com
  5. myMail.HTMLBody = strBody
  6. myMail.AddAttachment "C:\AttachmentFile.txt"
  7. myMail.Send
  8. set myMail=nothing
Dr B
Jun 12 '08 #8
thank u for ur reply,

actually i dont know all properties of CDOSYS like

Expand|Select|Wrap|Line Numbers
  1. Mailer.FromName = 
  2. Mailer.FromAddress = 
  3. Mailer.RemoteHost =  
  4. Mailer.ReturnReceipt = true
  5. Mailer.ConfirmRead = false
  6. Mailer.Priority = 0
  7. Mailer.Subject = subject
  8. Mailer.ContentType = "text/html"
  9. Mailer.BodyText = strBody
  10. Mailer.ClearRecipients        
  11. Mailer.AddRecipient 
  12. Mailer.AddRecipient 
  13. Mailer.AddAttachment
  14. 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.
Jun 12 '08 #9
979 Expert 512MB
No problem, check out w3Schools for some of the properties but there are loads of resources out there.

Dr B
Jun 12 '08 #10
hello DR.B,

thanx a lot for ur support.

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

thanx again..

keep replying.
Jun 13 '08 #11
979 Expert 512MB
Excellent Yash! Glad you got it sorted out.

Dr B
Jun 13 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Sam | last post: by
5 posts views Thread by Das | last post: by
2 posts views Thread by kamlai | last post: by
1 post views Thread by Second Chance | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.