?
Solved

change CDONTS  to CDO

Posted on 2005-04-30
17
Medium Priority
?
404 Views
Last Modified: 2012-08-13
how can i change this code to CDO

Set objMsg = Server.CreateObject("CDONTS.NewMail")

objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.Body = strBody
'objMsg.Importance = lngImportance
objMsg.AttachFile strFileName, ExportFileName
objMsg.Send

Set objMsg = Nothing
0
Comment
Question by:gianitoo
  • 8
  • 5
  • 3
  • +1
17 Comments
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13902526
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13902528
i know how to do everything except this line      objMsg.AttachFile strFileName, ExportFileName

can u help me?
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13902533
and has to be this code

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
myMail.Configuration.Fields.Update
myMail.Send
%>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Expert Comment

by:iscode
ID: 13902609
      set cdoMessage = Server.CreateObject("CDO.Message")
       set cdoConfig = Server.CreateObject("CDO.Configuration")
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPSERVER
       cdoConfig.Fields.Update
       set cdoMessage.Configuration = cdoConfig
       cdoMessage.From =  youremail
       'cdoMessage.ReplyTo = replyTo
       cdoMessage.To = CustomerEmail
       cdoMessage.TextBody = BODY              
       on error resume next
       cdoMessage.Send
       if Err.Number <> 0 then
         SendMail = "Email send failed: " & Err.Description & "."
       end if
       set cdoMessage = Nothing
       set cdoConfig = Nothing
0
 
LVL 6

Expert Comment

by:iscode
ID: 13902654
did that work for you?
0
 
LVL 6

Expert Comment

by:iscode
ID: 13902685
this is for AttachFiles
------------------------

for each file in Upload.Files
fn=File.ExtractFilename
cdoMessage.AttachFile Server.MapPath(fn),fn
next
0
 
LVL 6

Expert Comment

by:iscode
ID: 13902707
or like this
------------
cdoMessage.AttachFile Server.MapPath("attachedfile.zip")
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13902710

this is what i have so far but i need to add this line somehow
objMsg.AttachFile strFileName, ExportFileName


set cdoMessage = Server.CreateObject("CDO.Message")
       set cdoConfig = Server.CreateObject("CDO.Configuration")
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 192.168.111.2
       cdoConfig.Fields.Update
       set cdoMessage.Configuration = cdoConfig
       cdoMessage.From =  strFrom    
       cdoMessage.To = strTo
       cdoMessage.TextBody = strBody          
       on error resume next
       cdoMessage.Send
       if Err.Number <> 0 then
         SendMail = "Email send failed: " & Err.Description & "."
       end if
       set cdoMessage = Nothing
       set cdoConfig = Nothing


0
 
LVL 6

Expert Comment

by:iscode
ID: 13902726
hers is good source of information too

http://www.motobit.com/tips/detpg_send-email-from-asp/
0
 
LVL 6

Expert Comment

by:iscode
ID: 13902732
set cdoMessage = Server.CreateObject("CDO.Message")
       set cdoConfig = Server.CreateObject("CDO.Configuration")
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 192.168.111.2
       cdoConfig.Fields.Update
       set cdoMessage.Configuration = cdoConfig
       cdoMessage.From =  strFrom    
       cdoMessage.To = strTo
       cdoMessage.TextBody = strBody
cdoMessage.AttachFile strFileName, ExportFileName          
       on error resume next
       cdoMessage.Send
       if Err.Number <> 0 then
         SendMail = "Email send failed: " & Err.Description & "."
       end if
       set cdoMessage = Nothing
       set cdoConfig = Nothing

0
 
LVL 1

Author Comment

by:gianitoo
ID: 13902743
i got this error

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'cdoMessage.AttachFile'

/reports/missing-dynamic-cee.asp, line 174
0
 
LVL 6

Accepted Solution

by:
iscode earned 2000 total points
ID: 13902772
hmmm
try AddAttachment insted of AttachFile
0
 
LVL 6

Expert Comment

by:iscode
ID: 13902776
I think you need to upgrade
VBScript Scripting Engine
0
 
LVL 2

Expert Comment

by:Odyssey122
ID: 13909710
AttachFile Method (CDONTS NewMail Object)
The AttachFile method adds an attachment to the message by reading a file.

Syntax
objNewMail.AttachFile(Source [, FileName] [, EncodingMethod] )
 
objNewMail

Required. This NewMail object.

Source

Required. IStream object or String. The full path and file name of the file to be attached to the message, or a pointer to an IStream object containing the file data.

FileName

Optional. String. The file name to appear in the attachment's placeholder in the message. If FileName is not supplied, the file name from the Source parameter is used.

EncodingMethod

Optional. Long. The manner of encoding the attachment. The following values are possible:

EncodingMethod setting  Value  Description  
CdoEncodingUUencode      0     The attachment is to be in UUEncode format (default).  
CdoEncodingBase64          1     The attachment is to be in base 64 format.  


Remarks
The default value for the EncodingMethod parameter can change if you set the MailFormat property. If MailFormat is set to CdoMailFormatText, the default value is CdoEncodingUUencode. If MailFormat is set to CdoMailFormatMime, the default value is CdoEncodingBase64. However, if you add an attachment encoded in base 64 format, the value of the MailFormat property is automatically set to CdoMailFormatMime.

Only C/C++ and Java programs can use an IStream object for the Source parameter. They should pass an IUnknown object that returns an IStream interface in response to QueryInterface. Microsoft® Visual Basic® supports the IDispatch interface and not IUnknown, so it cannot use an IStream object.
0
 
LVL 2

Expert Comment

by:Odyssey122
ID: 13909774
Microsoft VBScript runtime error '800a01b6'  
Object doesn't support this property or method: '<property or method>'  
/<file>.asp, line <line>
 
Usually, this is because you used a property or method that doesn't exist, or doesn't exist in the version of the object you're using. For example, if you have MSXML 3.0 installed, and you try this code:
 
<%
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.setRequestHeader "User-Agent","foo"
%>
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13909822
thanks man...once i saw your awesome rsponse i realized that on friday i got it worked out with the last post by iscode.

thanks for all your help
0
 
LVL 2

Expert Comment

by:Odyssey122
ID: 13909850
Is all good, no harm done...  :)

Ody
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

809 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