Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Email with Java script without prompting user

Status
Not open for further replies.

Jokada

Programmer
Apr 29, 2004
24
BE
Hi,

I've got following VBscript that I would like to alter to java script:
This automatically sends an email without prompting the user.
Can this be done with Java script?? if so how?



VBscript:
============================================================
Set m_objCDO = CreateObject("CDO.Message")
Set m_objCDOcon = CreateObject("CDO.Configuration")

Const cdoSendUsingMethod = "Const cdoSendUsingPort = 2
Const cdoSMTPServer = "Const cdoSMTPServerPort ="Const cdoSMTPConnectionTimeout = "Const cdoSMTPAuthenticate = "Const cdoBasic = 1
Const cdoSendUserName = "Const cdoSendPassword = "
meldung = "Dear Sir, <br> your message"
'Sending email notification

Set Fields = m_objCDOcon.Fields
'Setting up Message parameters
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'Replace with your SMTP server
.Item(cdoSMTPServer) = "server"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 100
'Only used if SMTP server requires Authentication
'.Item(cdoSMTPAuthenticate) = cdoBasic
'.Item(cdoSendUserName) = "yourusername"
'.Item(cdoSendPassword) = "yourpassword"
.Update
End with

'Passing parameters to message object
Set m_objCDO.Configuration = m_objCDOcon

With m_objCDO
'Replace with email you wish the message to be sent to
.To = "somemail@mail.com"
'Replace with email you wish the message to be from
.From = "mail@microsoft.com"

' Attachment using known static physical path
'.AddAttachment "c:\Multiping.xls"
'.AddAttachment Server.MapPath("images/asp101-100x30.gif")
' Attachment added directly from a URL
'.AddAttachment " file.htm"
'Replace with subject
.Subject = "Test subject"
'Replace with information you want to be sent
.HTMLBody = meldung
.Send
End With
==================================================
Thanks!!
 
Comments aside, I'd hazard a guess that something like this might work:

Code:
var m_objCDO = Server.CreateObject('CDO.Message');
var m_objCDOcon = Server.CreateObject('CDO.Configuration');

var cdoSendUsingMethod = '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing';[/URL]
var cdoSendUsingPort = 2;
var cdoSMTPServer = '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver';[/URL]
var cdoSMTPServerPort = '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport';[/URL]
var cdoSMTPConnectionTimeout = '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout';[/URL]
var cdoSMTPAuthenticate =    '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate';[/URL]
var cdoBasic = 1;
var cdoSendUserName =    '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername';[/URL]
var cdoSendPassword =    '[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword';[/URL]

var meldung = 'Dear Sir, <br> your message';

var Fields = m_objCDOcon.Fields;
with (Fields) {
	Item(cdoSendUsingMethod) = cdoSendUsingPort;
	Item(cdoSMTPServer) = 'server';
	Item(cdoSMTPServerPort) = 25;
	Item(cdoSMTPConnectionTimeout) = 100;
	Update();
}

var m_objCDO.Configuration = m_objCDOcon;
with (m_objCDO) {
	To = 'somemail@mail.com';
	From = 'mail@microsoft.com';
	Subject = 'Test subject';
	HTMLBody = meldung;
	Send();
}

I cannot test it, as I don't have any server-side facilities right now... If it doesn't work, I suggest tweaking it / playing around / just trying stuff that seems logical.

Hope this helps,
Dan


The answers you get are only as good as the information you give!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top