Forum Discussion
Dmitry_Nikolaev
Staff
14 years ago
Hi Vidya,
In your original code, you use the local Outlook Express account with name 'mail.domain.com'. It is possible that this account exists on the XP machine, but does not exist on the Windows 7 machine. Please check whether you have this account on the Windows 7 machine.
I think that the better approach will be not using the local Outlook Express account, but specifying the credentials for the SMTP server account. Use this code for this:
function sendEmail(smtpServerName,smtpAccountName,fromAddress,toAddress,subject) {
try {
var objMessage = new ActiveXObject("CDO.Message")
var cdoConfig = new ActiveXObject("CDO.Configuration")
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServerName;
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""; // Specify account name here
cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""; // Specify account password
// cdoConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = smtpAccountName;
cdoConfig.Fields.Update();
objMessage.Subject = subject;
objMessage.From = fromAddress;
objMessage.To = toAddress;
objMessage.TextBody = "This is a test mail."
objMessage.Fields.Update();
objMessage.Send();
}
catch(exception) {
throw exception;
}
}
function sendTestMail(){
sendEmail("mail.domain.com","mail.domain.com",<From Address>,<To Address>,"Test Mail");
}
Before running the function, insert the valid account name and password to its code.
Please let me know if this helps.