Classic ASP CDO sendmail
FIXED- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Other forums
- :
- Tech Help - Software/Hardware etc
- :
- Re: Classic ASP CDO sendmail
11-07-2017 9:41 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
i've got a script where a use fills out a form and attaches a document.
the document gets uploaded to another internal sever (not the webserver), and then an email is sent to the use informing that it has been submitted etc etc.
what i am trying to do now is attached that uploaded file to the resulting email.
the webserver has access to the folder on the other server where the file is uploaded to.
the file is uploaded to \\servername\subfolder\filename.ext
the part i can't seem to get to work is the myMail.AddAttachment part
i already have the full path of the file set as a variable in the script (in this instance called "doctest".
Set myMail=CreateObject("CDO.Message") myMail.Subject="subject" myMail.AddAttachment Server.MapPath(doctest) myMail.To="test@test.com" myMail.TextBody=emailcontent
I get this error when trying this
Server.MapPath() error 'ASP 0174 : 80004005' Invalid Path Character(s) test.asp, line 77 An invalid '/' or '\' was found in the Path parameter for the MapPath method.
anyone any ideas if this should work?
Fixed! Go to the fix.
Re: Classic ASP CDO sendmail
11-07-2017 10:15 AM - edited 11-07-2017 12:27 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
It's been quite some time since I worked with Classic ASP, so maybe mis-remembering here. Doesn't Server.MapPath() give the full path from the relative path that you pass in as a parameter?
Since doctest is the full path to the file wouldn't it just be that which is assigned to the myMail,AddAttachment?
ie
myMail.AddAttachment doctest
Edit: Corrected code. I had a comma in where a full stop should have been.
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
Re: Classic ASP CDO sendmail
11-07-2017 11:49 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: Classic ASP CDO sendmail
12-07-2017 9:51 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
that didn't work sadly.
Object doesn't support this property or method: 'myMail.AddAttachment'
this is my test script
<% uploadedFilePath = "\\server\data\2503_2017071192320_test.pdf" Set myMail=CreateObject("CDO.Message") myMail.Subject="TEST" myMail.To="test@test.com" myMail.HTMLBody = "<h1>This is a message.</h1>" myMail.AddAttachment = uploadedFilePath myMail.From="test@test.com" myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mailserver.com" myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0 myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20 myMail.Configuration.Fields.Update myMail.Send set myMail=nothing %>
Re: Classic ASP CDO sendmail
12-07-2017 9:59 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
File paths and shares can be a pain when on other machines in any language. Also if your file storage server is turned off or rebooted when a user has submitted a file then your script can cache the uploads until that machine is seen online again via ping etc.
Re: Classic ASP CDO sendmail
12-07-2017 10:56 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
the user fills out the upload form, and it saves it direct to the final location.
the fact that it can upload to the final location means there is no problem with communication between the web and file server.
the file server is never turned off, it's a 24/7 operational system!
Re: Classic ASP CDO sendmail
12-07-2017 12:29 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I don't doubt both machines can communicate but it looks to me like a permissions problem or something with your language that is being problematic. What happens if your second machine develops a fault like a psu failure? - although rare, these things do happen. That's why I would save the file locally first, attach to email and send and THEN move it over to the other machine and delete the local copy. That way you have some protection if the other machine drops off the radar for any reason and it should simplify attaching your file too.
Re: Classic ASP CDO sendmail
12-07-2017 12:58 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
we are not talking about a PC in a corner running as a server here, we are talking corporate level business servers in a managed environment.
i know it's defintely not a permissions issue, so that can be ruled out.
it may be a code issue, and that's what i want to focus on in trying to resolve.
Re: Classic ASP CDO sendmail
12-07-2017 1:00 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@chenks76 - Have you tried:
myMail.AddAttachment(uploadedFilePath, username, password)
Where username / password are those needed to access the remote share.
Re: Classic ASP CDO sendmail
12-07-2017 1:07 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
12-07-2017 2:12 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
OK then try :
myMail.AddAttachment(uploadedFilePath)
Re: Classic ASP CDO sendmail
12-07-2017 2:22 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
probably the only combination that i never initially tried.
Re: Classic ASP CDO sendmail
12-07-2017 4:52 PM - edited 13-07-2017 7:54 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
So as you know why that works it is because .AddAttachment is a function, not a property. This function takes parameters, some optional; resource, username, password for example. However what you were trying to do is assign a value to the .AddAttachment function which of course was failing.
Re: Classic ASP CDO sendmail
13-07-2017 11:26 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@chenks76 wrote:
if the second machine develops a fault then the business ceases operating, and the ability to upload a file via a webserver becomes a moot point.
we are not talking about a PC in a corner running as a server here, we are talking corporate level business servers in a managed environment.
i know it's defintely not a permissions issue, so that can be ruled out.
it may be a code issue, and that's what i want to focus on in trying to resolve.
Even so surely the secondary system going belly up would make the primary server experience slightly borked?
As for a PC in the corner of the basement.. those are your words not mine. I never assumed anything like that. These days far too many people / organisations have access to hi end stuff and low end prices thanks to ebay etc.
Anyway good to hear that you got your problem resolved.
Re: Classic ASP CDO sendmail
13-07-2017 11:33 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
the webserver is the secondary system, and the file server is the primery server.
if the primary server is down then the secondary server, by default, is also down.
we have the usual enterprise grade UPS's installed and a backup diesel generator should there ever be a power outage.
should the hardware fail in the primary server then we have fail over, via fibre link, to a remote site that has a mirror copy of the primary server.
you created a problem that doesn't exist. the problem WAS code and was easily solved.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Other forums
- :
- Tech Help - Software/Hardware etc
- :
- Re: Classic ASP CDO sendmail