change CDONTS to CDO

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
LVL 1
gianitooAsked:
Who is Participating?
 
iscodeCommented:
hmmm
try AddAttachment insted of AttachFile
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
0
 
gianitooAuthor Commented:
i know how to do everything except this line      objMsg.AttachFile strFileName, ExportFileName

can u help me?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
gianitooAuthor Commented:
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
 
iscodeCommented:
      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
 
iscodeCommented:
did that work for you?
0
 
iscodeCommented:
this is for AttachFiles
------------------------

for each file in Upload.Files
fn=File.ExtractFilename
cdoMessage.AttachFile Server.MapPath(fn),fn
next
0
 
iscodeCommented:
or like this
------------
cdoMessage.AttachFile Server.MapPath("attachedfile.zip")
0
 
gianitooAuthor Commented:

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
 
iscodeCommented:
hers is good source of information too

http://www.motobit.com/tips/detpg_send-email-from-asp/
0
 
iscodeCommented:
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
 
gianitooAuthor Commented:
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
 
iscodeCommented:
I think you need to upgrade
VBScript Scripting Engine
0
 
Odyssey122Commented:
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
 
Odyssey122Commented:
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
 
gianitooAuthor Commented:
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
 
Odyssey122Commented:
Is all good, no harm done...  :)

Ody
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.