PDA

View Full Version : Using CDO.Message in Javascript


imchaz
02-09-2009, 10:11 AM
I have this code working in a previous provider but when I migrated it here I get an error. I coded this in Javascript.

So in the line where it states: objCDOMail.Send();

I get an error that appears on that asp page:

CDO.Message.1 error '80040220'
The 'SendUsing' configuration value is invalid.
test.asp, line ###

[quote]

varobjCDOMail=Server.CreateObject('CDO.Message');
varstrTo;
varstrFrom;
varstrCc;
varstrSubject;
varstrBody;
varLineBreak='\r\n';

//Firstwe'llreadinthevaluesenteredfromtheformintothe Localvariables
strFrom=Request.Form('hiddenFrom');//'MakesuretheFromfieldhasnospaces.
strTo=Request.Form('hiddenTo');

//GethiddenCCvaluesfromfunctionConverHideValues
strCc=Request.Form('hiddenCC');

strSubject='ThisIsaTestSubjectLine';
strBody='BodyTest';
strBody=strBody+LineBreak;

//'Setthepropertiesoftheobject
objCDOMail.From=strFrom;//'or'webperson@whatever.com'Youcanhardcodesomething too!
objCDOMail.To=strTo;
objCDOMail.Cc=strCc;
objCDOMail.Subject=strSubject;
objCDOMail.TextBody=strBody;

//'Sendthemessage!
objCDOMail.Send();

//'Settheobjecttonothingbecauseitimmediatelybecomes
//'invalidaftercallingtheSendmethod+itclearsitoutoft heServer'sMemory.

objCDOMail=null;
</CODE>

What do I have to change to make it work here on DiscountASP?

Thanks.

bruce
02-09-2009, 10:45 AM
see http://support.discountasp.net/KB/a327/send-mail-using-cdo.aspx

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

imchaz
02-10-2009, 03:49 AM
I found my solution and it worked for me. FYI if anyone is interested.

[quote]

varobjCDOMail=Server.CreateObject('CDO.Message');
varstrTo;
varstrFrom;
varstrCc;
varstrSubject;
varstrBody;
varLineBreak='\r\n';


//SettingtheConfiguration
objCDOMail.Configuration.Fields.Item('http://schemas.microsoft.com/cdo/configuration/sendusing')=2;
objCDOMail.Configuration.Fields.Item('http://schemas.microsoft.com/cdo/configuration/smtpserver')='localhost';
objCDOMail.Configuration.Fields.Update();

//Firstwe'llreadinthevaluesenteredfromtheformintothe Localvariables
strFrom=Request.Form('hiddenFrom');//'MakesuretheFromfieldhasnospaces.
strTo=Request.Form('hiddenTo');

//GethiddenCCvaluesfromfunctionConverHideValues
strCc=Request.Form('hiddenCC');

strSubject='ThisIsaTestSubjectLine';
strBody='BodyTest';
strBody=strBody+LineBreak;

//'Setthepropertiesoftheobject
objCDOMail.From=strFrom;//'or'webperson@whatever.com'Youcanhardcodesomething too!
objCDOMail.To=strTo;
objCDOMail.Cc=strCc;
objCDOMail.Subject=strSubject;
objCDOMail.TextBody=strBody;

//'Sendthemessage!
objCDOMail.Send();

//'Settheobjecttonothingbecauseitimmediatelybecomes
//'invalidaftercallingtheSendmethod+itclearsitoutoft heServer'sMemory.

objCDOMail=null;
</CODE>

imchaz
02-10-2009, 04:17 AM
Bruce,
Thanks for the reply. I have seen that link, but I dont know how to rewrite this piece properly into Javascript (ASP)

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

' Setting the SMTP Server
Set Flds = objConfig.Fields
Flds.Item('http://schemas.microsoft.com/cdo/configuration/sendusing') = 2
Flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserver') = 'localhost'
Flds.update

THe code is written in vbscript. I believe if someone could help me how to write it properly, it would solve my problem.