How to convert this vbscript in HTA ?

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Sat Jan 22, 2011 12:27 am

Hi !
I want to make a small dialog box asking for a few options, and then I want to take those options and send them via e-mail with a file in attachment by browsing it on my computer.
I already have a VBS script that sends e-mail, and I need to use HTA for my form.
How can I combine the VBS script into my HTA, or how can I pass the HTA values to my VBScript?
Here is my mail VBScript:

Code: Select all

sub main() 
Dim messageHTML 
Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = [stuff from the HTA] 
objMessage.From = [stuff from the HTA] 
objMessage.To = [stuff from the HTA] 
objMessage.TextBody = [stuff from the HTA] 
File= [stuff from the HTA] 'path of attachement 
messageHTML="This an example in HTML sended by hackoo" 
 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = [stuff from the HTA] 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
objMessage.Configuration.Fields.Update 
 
objMessage.HTMLBody="<center><font size=4 FACE=Tahoma Color=red>"&messageHTML&"<br><br><img src=http://photomaniak.com/upload/out.php/i1102064_IDNlogo.gif>" 
objMessage.AddAttachment(File) ' adding Attachment 
objMessage.Send 
 
     If Err.Number <>0 Then 
               MsgBox Err.Description,16,"Error" 
               msgbox "The mail isn't sended !",16,"Information" 
          Else 
          msgbox "The mail is sended sucessfully !",64,"Information" 
     End If 
          On Error GoTo 0 
 end sub 
Call main
Thank you !
Best Regards !

jvierra
Posts: 14045
Joined: Tue May 22, 2007 9:57 am
Contact:

How to convert this vbscript in HTA ?

Post by jvierra » Sat Jan 22, 2011 1:23 am

Start by creating your form as an HTA. Use a utton to call you VBS code.

Here is a link to the docs on how to build an HTA.

http://msdn.microsoft.com/en-us/library ... S.85).aspx

Here is a simple example

http://samples.msdn.microsoft.com/works ... simple.hta

Look in the sharing forum for more exmples.
http://www.scriptinganswers.com/forum2/ ... asp?FID=25


User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Sat Jan 22, 2011 1:50 pm

Here is a very simple example of an SMTP mail client redered with an HTA.
 uploads/2491/SmtpMailClient.zip
You will need to insert your smtp server address in the place reserved for it in the code.

THANK YOU VERY MUCH !
This code help me a lot and it works for me as a charm,and i modified it to add an attachment and a signature in a HTML Mode with image (^_^) and here is the code modified by me that can help someone else !
Please take a few time to test this and tell me your result !
Thank you again !
With My Best Regards !

SMTPCLIENT_Hackoo.ziphackoo2011-01-22 20:55:58

User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Sat Jan 22, 2011 5:22 pm

SOrry but your code is completely nonfunctional.  I don't understand why you made those changes. Your changes pertty much guarantee that it won't work.
Look at the original and don't make changes until you understand what is happening.
Your additions are jsst hacks that don't really do anything.  What is it that youare trying to do?  What you are trying to do is very hard to guess from what you have posted.

Ok i want to say that those addtions work for me perfectely and this thanks to you !
and it send me an email with attachment with signature in HTML.
Perhaps my SMTP server let me send this E-mail and yours NO or it is Blocked by your antivirus or your Firewall i don't know what you get like ERROR for Sending that ??
and this a proof :
hackoo2011-01-23 00:27:38

User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Sun Jan 23, 2011 1:21 am


Are you just trying to learn to write scripts?  Is this a school project?  Maybe that would explain what I see.

Hi ! Yes i just trying to learn to write scripts and you have right (^_^)
I have another idea in my mind: like adding in this script to get an advanced editor like BBCode so i know it's hard to code it but this my aim in the futur; So if you have another advices for this just let me know and you are welcome !
Thank you very much for your help !
With my Best Regards ! hackoo2011-01-23 08:37:15

jvierra
Posts: 14045
Joined: Tue May 22, 2007 9:57 am
Contact:

How to convert this vbscript in HTA ?

Post by jvierra » Sun Jan 23, 2011 8:12 am

Here is a more complete example of how to use vbscript and the DOM to manage an HTA. This has numerous expanded techniques that show how to implemet external data and how to use style sheets to manage the layout an style of your HTAs.

I will eventually post this in 'scritp sharing'

uploads/2491/SMTPMailClientPlus.zip

This code also shows how to use a control to input HTML from the user interface or from a file. The built in demo shows how the HTA can embed an image file into the mail message so it does not need to be stored on a public server. Many users including myself block external images to prevent tracking so only embedded images will be displyed on those systems.

jvierra2011-01-23 15:15:34

User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Wed Jan 26, 2011 11:30 am

I have another idea in my mind: like adding in this script to get an advanced editor like BBCode so i know it's hard to code it but this my aim in the futur; So if you have another advices for this just let me know and you are welcome !
Thank you very much for your help !
With my Best Regards !
Hi (^_^)
I found a good HTA script dealing with BBCode named Dingue_BBCode_Editor.0.5 it is an Off line forum message editor. So i have this idea to combine your script with this BBCode Editor. you can download the Original Script at this link
and my modification here in attachment
SMTP_Mail_Client-BBcode_Editor.ziphackoo2011-01-26 18:57:04

jvierra
Posts: 14045
Joined: Tue May 22, 2007 9:57 am
Contact:

How to convert this vbscript in HTA ?

Post by jvierra » Sat Feb 12, 2011 5:52 am

I just sent a message from Win7 and Vista with no issues. I didn't even elevate.

What errors are you getting. Maybe your system is damaged or infected which might cause a problem.

jvierra
Posts: 14045
Joined: Tue May 22, 2007 9:57 am
Contact:

How to convert this vbscript in HTA ?

Post by jvierra » Sat Feb 12, 2011 8:04 am

Sorry but I will not rewrite your (or anyone rlses code) for you.

It is your job to write the code. I will help you understand what you are doing wrong.

PLease do not post other peoples code or links to as if it is your own. If I had known that you did not write this I would have declined to comment.

The code is a major excercise. The author has done what he thinks is needed. I feel that it is a good exercize in learning an HTA. Looking at teh authors code will help you but you really need to start with the basics or none of it will make any sense.

The author told you what to look at. No you are asking me to look at it for you. How can you learn if I look at it.


User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to convert this vbscript in HTA ?

Post by hackoo » Tue Feb 15, 2011 9:53 pm

Thank you for your advice ! you have right this is a very good Exercise to learn from it so there are many features on it and to practise HTA and Vbscript Functions.So I modified it a little and i add a few lines. Now i want to know a Trick: how can i add flash

here is an example:

Code: Select all

    object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/{param}"></param><embed src="http://www.youtube.com/v/{param}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
Example : http://youtube.com/watch?v=JFwCCL0Vh6Uu ... ouTube.zip

Thank You
hackoo2011-02-16 05:03:59

Locked