Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



SEO Class in Chicago, IL

Learn How To Optimize Your Website on July 26, 2013


Looking for personalized in-depth SEO training among your peers?



High Rankings is offering a 1-day customized SEO training class in Chicago. Class size is limited so please sign-up now if you want in!



 


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Reg Sending Email


  • Please log in to reply
6 replies to this topic

#1 seo_bright

seo_bright

    HR 5

  • Active Members
  • PipPipPipPipPip
  • 292 posts

Posted 17 September 2008 - 08:43 AM

I am currently working on code in ASP Access for sending mail with the customer feedfack. One of the field is a File type input field where user browses locally and sends as attachment along with the mail. I checked many sites. Code for attaching it is working fine if its fixed like a url.

The code is
mailobj.AddAttachment "http://www.anysite.c...news/news.html" is working fine

but suppose I have to attach the file stored in the folder news dynamically based on imput from form it shows error as unable to locate file

I tried something like:

mailobj.AddAttachment "http://www.anysite.com/news/" & thefilenameVar

but shows error in that line. Plz help as I am new to ASP and coding.




#2 1dmf

1dmf

    Keep Asking, Keep Questioning, Keep Learning

  • Active Members
  • PipPipPipPipPipPipPip
  • 2,154 posts
  • Location:Worthing - England

Posted 17 September 2008 - 09:01 AM

if you alert/msgbox or what ever asp for display is, the variable 'thefilenameVar' does it contain what you expect?

Also would the path to a file ASP is trying to attach be a file path not a URL ?

i.e. C:\websites\myweb\news\filename

that's what it would be if I was using perl to attach a file to an email.

Edited by 1dmf, 17 September 2008 - 09:09 AM.


#3 Katy

Katy

    HR 3

  • Active Members
  • PipPipPip
  • 68 posts
  • Location:Oxford, England

Posted 17 September 2008 - 10:52 AM

I think you need to use Server.MapPath to find the physical location of the file.

Example:

You're running the mail script from www.mysite.com/sendmail.asp

The file you want to attach is in www.mysite.com/news/ [any file name]

To attach it I think you need to do the following:

CODE
mailobj.AddAttachment Server.MapPath("news/"&theFileName)


But, as 1DMF says, you may need to check that the file name is being passed correctly to your variable to do this, above the line that's giving you the error put:

CODE
Response.Write "thefilenameVar = "&thefilenameVar
Response.END


That will write out what's in your variable and stop the script from executing so you can have a look at it.

#4 seo_bright

seo_bright

    HR 5

  • Active Members
  • PipPipPipPipPip
  • 292 posts

Posted 18 September 2008 - 06:14 AM

Hi thank you guys for your prompt responses. I tried something like what u have provided but keep getting error as Path not found , so I tried this way
.AddAttachment Server.MapPath(".") & "\news\" & theFileName.

It worked both in local and online.

#5 1dmf

1dmf

    Keep Asking, Keep Questioning, Keep Learning

  • Active Members
  • PipPipPipPipPipPipPip
  • 2,154 posts
  • Location:Worthing - England

Posted 18 September 2008 - 06:31 AM

The error may be because the path dilemiter in Katy's example was the wrong way round?

forward slash vs backslash?

#6 Katy

Katy

    HR 3

  • Active Members
  • PipPipPip
  • 68 posts
  • Location:Oxford, England

Posted 18 September 2008 - 06:34 AM

1DMF - You're probably right - I always seem to get them confused.

After 15 years you would have thought I'd remember by now poster_oops.gif

#7 1dmf

1dmf

    Keep Asking, Keep Questioning, Keep Learning

  • Active Members
  • PipPipPipPipPipPipPip
  • 2,154 posts
  • Location:Worthing - England

Posted 18 September 2008 - 07:30 AM

hey no worries, i'm sure we all do it all the time, especially if you flit between URL's / Windows format and *nix , I never know whether i'm forwards (coming) or backwards (going) huh.gif




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users