Log in

View Full Version : edit asp code to match with host server



sandra
07-05-2008, 10:07 AM
i have a asp code for my page and our host service wants from it's customer to change it like sample code.
could any one help me to edit this code:

my code:

<%@ CodePage = "1252" Language = "VBScript" %>
<% Option Explicit %>
<% Response.CharSet = "utf-8" %>

<%

dim strDate, strToAddress, strFromAddress, strMailSubject, strMailServerName, _
strCcAddress, strBccAddress, strAttachmentFile, errormsg


strDate=year(date()) & "/" & month(date()) & "/" & day(date())

'------------------------------------------------------------------[Call Mail Sender Function - CDO]
strToAddress = "yourname@domain.com"
if Not (request.form("Email") = "" ) then
strFromAddress = request.form("Email")
else
strFromAddress = "yourname@domain.com"
end if

strMailSubject = "test [" + strDate + " ]"
strMailServerName = "mail.domain.com"
strCcAddress = strFromAddress
strBccAddress = ""
strAttachmentFile = ""

sendEmail strToAddress, strFromAddress, strMailSubject, strMailServerName, strCcAddress, strBccAddress, strAttachmentFile, strDate

Sub sendEmail(strToAddress, strFromAddress, strMailSubject, strMailServerName, strCcAddress, strBccAddress, strAttachmentFile, strDate)
dim txtBody, objMail
txtBody = ""
txtBody = " my codeeeeeeeeeeeeeeeeee"
txtBody = Replace( txtBody, "~~", VBCRLF)
' response.write txtBody
' response.end
dim objConfig, sch
on error resume next
' Set objMail = Server.CreateObject("CDONTS.NewMail")
Set objMail=CreateObject("CDO.Message")
'Set objConfig = CreateObject("CDO.Configuration")
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set objConfig = CreateObject("CDO.Configuration")

With objConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mail.overclocking.ir"
.Item(sch & "smtpserverport") = 25
.update
End With

Set objMail.Configuration = objConfig

'objMail.BodyFormat = 0 ' set to 1 for palin text
'objMail.MailFormat = 0 ' set to 1 for palin text
objMail.From = strFromAddress
objMail.Subject = strMailSubject
objMail.To = strToAddress
objMail.Cc = strCcAddress
objMail.Bcc = strBccAddress
objMail.HTMLBody = txtBody + "<font color='#C0C0C0' face='Tahoma' size='2'>" + strDate + "</font>"
' objMail.AttachFile = ""
'objMail.Importance = 1 ' Low importance=0 / Normal importance=1 / High importance=2
objMail.Send
Set objMail = Nothing
'---------------------------------------------------------------[Error on Send Email]
if err.number <> 0 then
'display message explaining failure
'Response.Write(err.number)
'response.Write(err.Description)
errormsg = "For more information see the following Error Message:"
%>
<!-- #include file="send_error.asp"-->
<%
Response.End
end if

End Sub

%>






the sample code (which i should use to work correctly with host):


<%

set objMessage = createobject("cdo.message")
set objConfig = createobject("cdo.configuration")

' Setting the SMTP Server
Set Flds = objConfig.Fields
Flds.Item("http://....") = 2
Flds.Item("http://....") = "mail.yourdomain.com"
Flds.Item("http://....") = 1
Flds.Item("http://....") = "you@yourdomain.com"
Flds.Item("http://....") = "YourMailboxPassword"

Flds.update


Set objMessage.Configuration = objConfig
objMessage.To = "someone@somewhere.com"
objMessage.From = "you@yourdomain.com"
objMessage.Subject = "This is a sample email sent using CDO"
objMessage.TextBody = "Congratulation" & VbCrLf & "If you receive this is, your mail component works"
objMessage.fields.update
objMessage.Send

Response.write "Mail sent..."

set objMessage = nothing
set objConfig = nothing

%>