Solved

How do I send an attached file using CDOSYS?

Posted on 2004-08-24
42
1,219 Views
Last Modified: 2008-02-20
I can't find the property that would add an attachement to the email.

MyMail.AddAttachment  doesn't work.

I have search EE and Microsoft's site. I just want to attach and send a file specified in the file field.

IF you know the answer, could you be kind enough to post a link to all the properties available for CDOSYS.  Microsoft's sites seem impenetrable to me.

Here's my code right now:


dim fileattach
fileattach = request.form("fileattachment")

strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<p>" &message& "</p>"
strHTML = strHTML & "-------------------------------------------------------"
strHTML = strHTML & "<br>Message generated by <a href='http://www.aurafellows.net'>AuraFellows.net</a>, built by <a href='http://www.saneplanet.com'>SanePlanet.com</a></p>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"


Set MyMail = CreateObject("cdo.message")
MyMail.From = "admin@aurafellos.net"
MyMail.To = "admin@aurafellos.net"
MyMail.Subject = subject
'MyMail.TextBody  = Totalmessage
MyMail.ReplyTo = emailfield
MyMail.HTMLBody = strHTML
 = fileattach
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "a"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyMail.Configuration.Fields.Update
MyMail.SEND
0
Comment
Question by:polaatx
  • 21
  • 19
  • 2
42 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 11885842
Use AddAttachment
0
 

Author Comment

by:polaatx
ID: 11885919
This is the error I get when I use

MyMail.AddAttachment = fileattach

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'MyMail.AddAttachment'

/aura/upload.asp, line 47
0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 11885976
Woops sorry...

Can you send mail without using an attachment?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886091
From our friend ap sajith:

<%
 ** SUBROUTINE TO SEND EMAIL USING CDOSYS **

'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","c@d.com","test",strMailBody,True,"mail.yahoo.com","")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
          ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTo
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
               
               ' ** SET Attachments If any **
            If sAttachPath<>"" Then
            .AddAttachMent (sAttachPath)    
            End if
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub

%>

FtB
0
 

Author Comment

by:polaatx
ID: 11886421
Fritz,

I am getting the error below, so .AddAttacment property definitely doesn't work for me. Could it be that the host has disabled it?

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'MyMail.AddAttachment'

/aura/upload.asp, line 47
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886460
It might also be a permissions issue--don't forget, the attachment has to come from a directory on the server, and if you don't have permissions to that directory, you will get some sort of error.

What if you put your attachement in the same directory as your mail page for now just to test?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886491
So, this won't work:

fileattach = request.form("fileattachment")
MyMail.HTMLBody = strHTML
 = fileattach

especially if you are trying to grab a file from the client machine!!!


FtB
0
 

Author Comment

by:polaatx
ID: 11886558
What do you mean by this:

>>What if you put your attachement in the same directory as your mail page for now just to test?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886607
So let's say that you want to attach a file called Resume.doc, then put that .doc file in the same directory as your .asp page that sends the mail. The you would do:

 MyMail.AddAttachMent ("Resume.doc")

FtB
0
 

Author Comment

by:polaatx
ID: 11886654
Fritz,

I think I didn't explain myself well. The file is not the server. It is in the client's computer.

So the above excerise with resume.doc would apply to me?

0
 

Author Comment

by:polaatx
ID: 11886677
thunderchicken:
>Can you send mail without using an attachment?

yes. I do send html mail using the code I posted with my question.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886736
polaatx--

I already said above, you can't do that with CDO. You can only send files that are on your server, and that is why you are getting the error.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886742
What you will have to do is to upload the file first, and then send it.

FtB
0
 

Author Comment

by:polaatx
ID: 11886768
Fritz,

I still get the same error using a file on the same directory as my asp script: repeatables.txt

Here is my code:

 Set MyMail = CreateObject("cdo.message")
MyMail.From = "admin@aurallows.net"
MyMail.To = "admin@auraflows.net"
MyMail.Subject = subject
'MyMail.TextBody  = Totalmessage
MyMail.ReplyTo = Session("MM_Username")
MyMail.HTMLBody = strHTML
MyMail.AddAttachment = ("repeatables.txt")
0
 

Author Comment

by:polaatx
ID: 11886797
Oh, I didn't know I need to upload it first. So I need to put in script for aspUpload earlier in the page. Save the file and then run the script to send the mail. Correct? All in the same file.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11886904
Now you are on it.

Ultimately, you can put the uploads in a different directory, but it is best to start off simple.

FtB
0
 

Author Comment

by:polaatx
ID: 11887111
Back to the question, do you know why I keep getting the .AddAttacment error?

I called the host (Brinkster) and they said they have no restrictions or modifications on that.

Here's what I have right now:

Set MyMail = CreateObject("cdo.message")
MyMail.From = "admin@aurallows.net"
MyMail.To = "admin@auraflows.net"
MyMail.Subject = subject
'MyMail.TextBody  = Totalmessage
MyMail.ReplyTo = Session("MM_Username")
MyMail.HTMLBody = strHTML
MyMail.AddAttachment = ("repeatables.txt")
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887120
do you have a file named repeatables.txt in the same directory as the code that sends the mail?

FtB
0
 

Author Comment

by:polaatx
ID: 11887138
yes. definitely
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887147
Just for fun, can you send using the script that I posted above?


ftB
0
 

Author Comment

by:polaatx
ID: 11887254
It doesn't generate an error, but the mail never arrives.

Here's the code. I had to add configuration properties because my host uses authentication. could it because not all the variables are defined?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


<%
 '** SUBROUTINE TO SEND EMAIL USING CDOSYS **

'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","c@d.com","test",strMailBody,True,"mail.yahoo.com","")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER *              
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
              .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
              .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "admin@admin.com"
                  .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
                   ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = "admin@aurafellows.net"

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = "admin@aurafellows.net"
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = "testing sending attachements"
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
               
               ' ** SET Attachments If any **
            If sAttachPath<>"" Then
            .AddAttachMent ("repeatables.txt")    
            End if
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body> Hello

</body>
</html>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:polaatx
ID: 11887435
Fritz,

The .AddAttachment part was inside an if/then statement and wasn't running. When i took out the conditional, then it generated a "CDO.Message.1 error '800c000d'

The specified protocol is unknown.

/aura/upload_fritzscript.asp, line 52

Then I realized in the script you sent me, there is = sign
so I changed
  .AddAttachMent ("repeatables.txt")  
to
  .AddAttachMent = ("repeatables.txt")  

But now it generates this error again:

CDO.Message.1 error '800c000d'

The specified protocol is unknown.

/aura/upload_fritzscript.asp, line 52
0
 

Author Comment

by:polaatx
ID: 11887438
I mean in your script there IS NO = sign
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887441
Okay, I don't see that you make the call to the sub anywhere?

<%
strMailBody= "This is the body text!"
Call SendMailCDOSYS("admin@aurallows.net","admin@auraflows.net","test mail",strMailBody,True,"sendmail.brinkster.com","repeatables.txt")
%>

FtB
0
 

Author Comment

by:polaatx
ID: 11887515
Okay, I redid everything, matching the exact style of the script you posted. Now I get

Microsoft VBScript compilation error '800a03f6'

Expected 'End'

/aura/upload_fritzscript.asp, line 61


By the way, it shoud be     .AddAttachMent =("repeatables.txt")   with a = sign, correct?

Here's my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


<%
 '** SUBROUTINE TO SEND EMAIL USING CDOSYS **

strMailBody= "This is the body text!"
CALL SendMailCDOSYS("aurafellows.net","aurafellows.net","test",strMailBody,True,"sendmail.brinkster.com","repeatables.txt")
Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)

     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER *            
               .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
            
              .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "admin@aurafellows.net"
                  .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "aura1234"
                    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
                   ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTO
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
               
               ' ** SET Attachments If any **

            .AddAttachMent =("repeatables.txt")    

           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body> Hello

</body>
</html>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887619
You need an END SUB around line 62.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887621
Like this:

     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
end sub
%>


FtB
0
 

Author Comment

by:polaatx
ID: 11887638
Sorry about all the hand holding.

Okay, it runs now and generates this error again:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'AddAttachMent'

/aura/upload_fritzscript.asp, line 52
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887701
Is this any better:

           .AddAttachMent ="repeatables.txt"

i.e., without the parenthesis?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887705
Oh, no equals sign either, I think that should be:

     .AddAttachMent "repeatables.txt"


FtB
0
 

Author Comment

by:polaatx
ID: 11887810
No, whenever = is not present it generates this:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'AddAttachMent'

/aura/upload_fritzscript.asp, line 52
0
 

Author Comment

by:polaatx
ID: 11887823
I mean this:
CDO.Message.1 error '800c000d'

The specified protocol is unknown.

/aura/upload_fritzscript.asp, line 52
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887913
Okay, I am making progress here--I haven't used this to send attachments before, so there is a bump or two in the road.

What needs to happen is this:

 .AddAttachMent ="repeatables.txt"


should be:

 .AddAttachMent Server.MapPath("repeatables.txt")

Here is the code that I am using without problem (mail server and email addresses changed to protect the innocent):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<body>
Hey!

<%
'** SUBROUTINE TO SEND EMAIL USING CDOSYS **

'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","c@d.com","test",strMailBody,True,"mail.yahoo.com","")

Dim strMailBody
strMailBody="Test HTML String with attachment!"
CALL SendMailCDOSYS("Someone@Somewhere.com", "Someone@Somewhere.com", "test", strMailBody, "True", "my.mail.com","data.txt")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
          ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTo
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
               
               ' ** SET Attachments If any **
           ' If sAttachPath<>"" Then
            .AddAttachMent Server.MapPath("data.txt")  
          '  End if
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub

%>
</BODY>
</HTML>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887917
So the long and short of it is that CDO requires a fully qualified path.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11887937
So, we should set this:

               ' ** SET Attachments If any **
           ' If sAttachPath<>"" Then
            .AddAttachMent Server.MapPath("data.txt")  
          '  End if

back to this:

               ' ** SET Attachments If any **
            If sAttachPath<>"" Then
                .AddAttachMent  sAttachPath
            End if


and then before calling the function, we should do:
sAttachPath = Server.MapPath("repeatables.txt")
Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)

FtB
0
 

Author Comment

by:polaatx
ID: 11888765
Thanks Fritz.

I think we're making progress. Now at least I get a new error:

error '8004020e'
/aura/upload_fritzscript.asp, line 60


This is in top:

sAttachPath = Server.MapPath("repeatables.txt")
strMailBody= "This is the body text!"
CALL SendMailCDOSYS("aurafellows.net","aurafellows.net","test",strMailBody,True,"sendmail.brinkster.com",sAttachPath)
Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)

And this is bottom:

                          ' ** SET Attachments If any **
            If sAttachPath<>"" Then
                .AddAttachMent sAttachPath
            End if
0
 

Author Comment

by:polaatx
ID: 11889141
To clarify, when I take out this part:

    ' ** SET Attachments If any **
            If sAttachPath<>"" Then
                .AddAttachMent sAttachPath
            End if


The mail goes through fine.
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 11891569
Okay, just for kicks, do this instead:

   ' ** SET Attachments If any **
             .AddAttachMent Server.MapPath("repeatables.txt")  
           
0
 

Author Comment

by:polaatx
ID: 11894911
With this     .AddAttachMent Server.MapPath("repeatables.txt")  
I am getting this error:

error '8004020e'
/aura/upload_fritzscript.asp, line 59

Line 59 is .send
0
 

Author Comment

by:polaatx
ID: 11895131
Fritz,

I had a reply to my post on the forum of my host. He says I have to use an absolute path. So I tried this:
             .AddAttachMent ("\\premfs14\sites\premium14\aasg\webroot\aura\repeatables.txt")

and I'm still getting the error '8004020e' /aura/upload_fritzscript.asp, line 59

But when I change the path, I get this:

CDO.Message.1 error '80070003'

The system cannot find the path specified.

/aura/upload_fritzscript.asp, line 54


So it is seeing the path. It seems to me the path is not the problem. It is something else in the script.

This is how it is right now:


<%
 '** SUBROUTINE TO SEND EMAIL USING CDOSYS **
sAttachPath = "\\premfs14\sites\premium14\aasg\webroot\aura\repeatables.txt"
strMailBody= "This is the body text!"
CALL SendMailCDOSYS("aurafellows.net","aurafellows.net","test",strMailBody,True,"sendmail.brinkster.com",sAttachPath)
Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer,sAttachPath)

     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER *            
               .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
            
              .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "admin@aurafellows.net"
                  .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "aura123ad4"
                    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
                   ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTO
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
               
               ' ** SET Attachments If any **

                          ' ** SET Attachments If any **
            If sAttachPath<>"" Then
               .AddAttachMent ("\\premfs14\sites\premium14\aasg\webroot\ura\repeatables.txt")

            End if
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End sub
%>
0
 

Author Comment

by:polaatx
ID: 11895487
Okay, I went back to my old script and put in the absolute path and now it works.

Something about the script you posted that conflicts with my server but I never figured it out. Pretty sure it had to do with authentication. That's what the error '8004020e'  is about. Thanks for your patience and trying.

Here's what works for me now:

Set MyMail = CreateObject("cdo.message")
MyMail.From = "admin@aurafellows.net"
MyMail.To = "chris@planet.com"
MyMail.Subject = "testing upload.asp"
'MyMail.TextBody  = Totalmessage
MyMail.ReplyTo = Session("MM_Username")
MyMail.HTMLBody = strHTML
MyMail.AddAttachment ("\\premfs14\sites\premium14\aasg\webroot\aura\repeatables.txt")
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail.brinkster.com"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "admin@aurafellows.net"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "auraasdf1234"
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyMail.Configuration.Fields.Update
MyMail.SEND
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11897863
I am glad that this is set and am sorry that it took so long to get it right.

FtB
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now