Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: My syntactical ignorance


Message #1 by "Peter Byers" <pb@s...> on Wed, 19 Mar 2003 07:25:56
I just have sendmail function written in javascript ..Just have alook at the
code.It may be helpful..
Even u do have javamail.
Code:

 String aToAddress = "slakshmi@i...";
String pSubject = "Java Mail";
String pMessage = "Test Mail from Java";
file://Be sure to give the absolute path name starting from where the JavaTM
Virtual Machine1 (JVM) is running.


  Message msg = new MimeMessage(session);
   msg.setFrom( aDefaultFromAddress );
   InternetAddress[] address = {aToAddress};
   msg.setRecipients(
        Message.RecipientType.TO, address);
   msg.setSubject( pSubject );
   msg.setSentDate(new java.util.Date());
   // create and fill the first message part
   MimeBodyPart mbp1 = new MimeBodyPart();
   mbp1.setText(pMessage);
   // create the second message part
   MimeBodyPart mbp2 = new MimeBodyPart();
   // attach the file to the message
   FileDataSource fds=   new FileDataSource(pFileName);
   mbp2.setDataHandler( new DataHandler(fds));
  //mbp2.setFileName(pFileName);
   // create the Multipart and its parts to it
   Multipart mp = new MimeMultipart();
   mp.addBodyPart(mbp1);
   //mp.addBodyPart(mbp2);
   // add the Multipart to the message
   msg.setContent(mp);
   Transport.send(msg);
System.out.println("mail sent");

Cheers,
Sree.

----- Original Message -----
From: "Peter Byers" <pb@s...>
To: "javascript" <javascript@p...>
Sent: Wednesday, March 19, 2003 7:44 AM
Subject: [javascript] RE: My syntactical ignorance


> Thank you Roy for your suggestion
>
> I had already tried that
>      It does not give me an error - it just does not send the EMail
>
> :-((
>
> Pete (Northolt UK)
>
>
>
> > dunno for sure but my guess would be that you need parens as in
>
> Mailer.SendMail();
>
> since javascript is c-based.
>
> The control may even force you to use javascript capitalization
> conventions:
>
> Mailer.sendMail();
>
> -Roy
>
> -----Original Message-----
> From: Peter Byers [mailto:pb@s...]
> Sent: Wednesday, March 19, 2003 7:26 AM
> To: javascript
> Subject: [javascript] My syntactical ignorance
>
>
> Good Morning Folks
>
> I have a .VBS file that works - it is shown below.
>
> For reasons that I will not go into, I need to convert it to
> JScript.
>
> I have never written JScript before
> BUT
> I will learn, I promise
>
>
> The .JS file below is my attempt at convertion from .VBS
>
>
> When I try it, it tells me that
> 'Mailer.SendMail' - Object doesn't support this property
> or method
>
> Well it manifestly does 'cos it works in VBS
> SO
> It must be my ignorance of JScript syntax
> PLEASE
> Will someone tell me what the JScsript should be
>
> Thank you in anticipation (I hope)
> Pete (Northolt UK)
>
>
>
> ******************************
> ******************************
> *****  VBS file         ******
> ******************************
> ******************************
> Dim Mailer, reply
>
> Set Mailer = CreateObject("SoftArtisans.SMTPMail")
>
> Mailer.FromName = "Byers"
>
> Mailer.FromAddress = "pb@m..."
>
> mailer.addrecipient "pedro", "pedro@m..."
>
> Mailer.bodytext = "a VBS test"
>
> mailer.organization = "My Company"
>
> mailer.ReplyTo = "pb@m..."
>
> mailer.subject = "a VBS test"
>
>
> strMailHost = "mail.igw.net"
> if strMailHost = "mailhost.xyz.com" then
>
> else
> Mailer.RemoteHost = strMailHost
> end if
>
>
> reply = Mailer.SendMail
>
>
>
>
> ******************************
> ******************************
> *****   JS file         ******
> ******************************
> ******************************
> var Mailer, reply;
>
> Mailer = new ActiveXObject("SoftArtisans.SMTPMail");
>
> Mailer.FromName = "Byers";
>
> Mailer.FromAddress = "pb@m...";
>
> Mailer.addrecipient("pedro", "pedro@m...");
>
> Mailer.bodytext = "a JS test";
>
> Mailer.organization = "My Company";
>
> Mailer.ReplyTo = "pb@m...";
>
> Mailer.subject = "a JS test";
>
>
> strMailHost = "mail.igw.net";
> if (strMailHost = "mailhost.xyz.com")
> {}
> else
> {Mailer.RemoteHost = strMailHost}
>
>
>
> reply = Mailer.SendMail;
>
>
>


  Return to Index