Link to home
Create AccountLog in
Avatar of bsharath
bsharathFlag for India

asked on

Need a Hta file to act to sent mails to specific address with data.

Hi,

Need a way to raise call in my OV.
When we send a mail to a email id.With "New" as the subject the OV automatically raises a call log.So what i though was is there a way an HTA file has this email id prefixed in the code and the subject in the code.And even the Mail header " This mail is to disable account"
When i need to send mails i can use this Hta instead of outlook.Like i need to raise 30+ calls every day.On various topics.
This would ease the job so much that paste the data in the provided space and just click a button.

Is there any way anyone can create one like this.
Thanks in advance...
Mainly without the outlook security waring on every mail sent.

Regards
Sharath
Avatar of David Lee
David Lee
Flag of United States of America image

Sharath,

Sorry, but I don't understand the question at all.  For example, what's "OV" mean, what do you mean when you say "raises a call log"?  
Avatar of bsharath

ASKER

OV is a software that we use to raise call logs.Its HP Open View software.
It have a machanisam that when a nail sent to it with the subject as "New" it automatically generates a call log on the name of the sender.
Its easy to send a mail rather then open the software and fill in all the 10+ fields.
I though a Hta file would be much more easier.
The subject,Body,Sender and To can be predefined.
A small text box that can fit say 150 + words.
When i need to raise a call log i can just put the txt in the box and click send.

Hope this is clear if not please let me know....
Ok, give this a try.  Copy and paste the code into Notepad and save with a .hta extension.  

If you don't like dealing with Outlook security, then I recommend downloading a copy of VBSendMail (it's free) and use it to send instead of Outlook.  
<html>
<head><title>Send Call Log</title>
<HTA:APPLICATION ID="oHTA";
  APPLICATIONNAME="CallLog";
  BORDER="thin";
  BORDERSTYLE="normal";
  SINGLEINSTANCE="no";
>
</head><body bgcolor="#E8E8E8" >
<font size=2 face="Century Gothic, Tahoma, Arial" color="black">
<script language="VBScript" type="text/vbscript">
	Sub SendCallLog
		Dim olkApp, olkSes, olkMsg
		Set olkApp = CreateObject("Outlook.Application")
		Set olkSes = olkApp.GetNameSpace("MAPI")
		olkSes.Logon
		Set olkMsg = olkApp.CreateItem(0)
		With olkMsg
			.Subject = "This mail is to disable account"
			.Recipients.Add "Someone@company.com"
			.Body = MsgTxt.value
			.Send
		End With
		Set olkMsg = Nothing
		olkSes.Logoff
		Set olkSes = Nothing
		Set olkApp = Nothing
	End Sub
//-->
</script>
<p><b>Send Call Log HTA by BlueDevilFan (3/2008)</b><hr noshode color="#000000"><br>
	<table>
		<tr>
			<td valign="top">Message:</td>
			<td><textarea name="MsgTxt" cols="50" rows="7"></textarea></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td valign="top"><input type="submit" name="B1" value="Submit"  onclick="SendCallLog"></td>
		</tr>
 	</table>
<script language="JavaScript">
<!--
	if (window.resizeTo) self.resizeTo(600,400);
//-->
</script>

Open in new window

Thanks for this..
Should i download the file from here
http://www.freevbcode.com/ShowCode.Asp?ID=109
And is it a setup?
Yes, download the code from there.  The piece you want is the DLL.  All you have to do is drop it in a folder and register it using the following command:

   REGSVR32 Drive:\PathToDLL\vbsendmail.dll

I'll go ahead and modify the code to use vbsendmail instead of Outlook.
Ok Bluedevil Fan     thanks...
Try this version with vbSendMail.  You'll need to edit it and fill in the values for the various vbSendMail properties.
<html>
<head><title>Send Call Log</title>
<HTA:APPLICATION ID="oHTA";
  APPLICATIONNAME="CallLog";
  BORDER="thin";
  BORDERSTYLE="normal";
  SINGLEINSTANCE="no";
>
</head><body bgcolor="#E8E8E8" >
<font size=2 face="Century Gothic, Tahoma, Arial" color="black">
<script language="VBScript" type="text/vbscript">
    Sub SendCallLog
        Dim poSendMail
        set poSendMail = CreateObject("vbSendMail.clsSendMail")
        With poSendMail
            .SMTPHost = "SMTP Server Name or IP Address"
            .From = "YourMailAddress@company.com"
            .FromDisplayName = "YourNameOrOtherText"
            .Recipient = "Someone@company.com"
            .RecipientDisplayName = "Recipient'sNameOrOtherText"
            .Subject = "This mail is to disable account"
            .Message = MsgTxt.value
            .Send
        End With
        Set poSendMail = Nothing
    End Sub
//-->
</script>
<p><b>Send Call Log HTA by BlueDevilFan (3/2008)</b><hr noshode color="#000000"><br>
    <table>
        <tr>
            <td valign="top">Message:</td>
            <td><textarea name="MsgTxt" cols="50" rows="7"></textarea></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td valign="top"><input type="submit" name="B1" value="Submit"  onclick="SendCallLog"></td>
        </tr>
    </table>
<script language="JavaScript">
<!--
    if (window.resizeTo) self.resizeTo(600,400);
//-->
</script>

Open in new window

To register
I gave this
REGSVR32 d:\vbsendmail.dll

I get this...

[Window Title]
RegSvr32

[Content]
The module "d:\vbsendmail.dll" was loaded but the call to DllRegisterServer failed with error code 0x80004005.

For more information about this problem, search online using the error code as a search term.

[OK]
To register
I gave this
REGSVR32 d:\vbsendmail.dll

I get this...

[Window Title]
RegSvr32

[Content]
The module "d:\vbsendmail.dll" was loaded but the call to DllRegisterServer failed with error code 0x80004005.

For more information about this problem, search online using the error code as a search term.

[OK]
Bluedevilfan
Any way to insert this method in the Hta

Public Sub NewCDOMessage(strSubject As String, strbody As String, Optional strTo As String, _
                            Optional strCC As String, Optional strBCC As String, Optional SendYN As Boolean, _
                            Optional AttachYN As Boolean = False, Optional Attach1 As String)

    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Variant

    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")

    iConf.Load -1    ' CDO Source Defaults
'    Set Flds = iConf.Fields
'    With Flds
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
'                       = "MYIPSMTPSERVER"
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MTIPACCOUNT"
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MYACCTPASSWORD"
'
'        .Update
'    End With

    With iMsg
        Set .Configuration = iConf

        .To = strTo
        If strCC <> "" Then .CC = strCC
        If strBCC <> "" Then .BCC = strBCC
        .From = "Email address"
        .Subject = strSubject
        .TextBody = strbody
        If AttachYN And Attach1 <> "" Then .AddAttachment Attach1
        .Send
    End With
End Sub


From this Q...
https://www.experts-exchange.com/questions/23222914/The-macro-needs-to-save-the-sheets-data-in-a-txt-file-as-the-sheets-name-and-send-a-mail-to-the-email-id-mentioned-in-column-A.html?anchorAnswerId=21093018#a21093018
ID: 21093018
Bluedevilfan
Any way to insert this method in the Hta

Public Sub NewCDOMessage(strSubject As String, strbody As String, Optional strTo As String, _
                            Optional strCC As String, Optional strBCC As String, Optional SendYN As Boolean, _
                            Optional AttachYN As Boolean = False, Optional Attach1 As String)

    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Variant

    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")

    iConf.Load -1    ' CDO Source Defaults
'    Set Flds = iConf.Fields
'    With Flds
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
'                       = "MYIPSMTPSERVER"
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MTIPACCOUNT"
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MYACCTPASSWORD"
'
'        .Update
'    End With

    With iMsg
        Set .Configuration = iConf

        .To = strTo
        If strCC <> "" Then .CC = strCC
        If strBCC <> "" Then .BCC = strBCC
        .From = "Email address"
        .Subject = strSubject
        .TextBody = strbody
        If AttachYN And Attach1 <> "" Then .AddAttachment Attach1
        .Send
    End With
End Sub


From this Q...
https://www.experts-exchange.com/questions/23222914/The-macro-needs-to-save-the-sheets-data-in-a-txt-file-as-the-sheets-name-and-send-a-mail-to-the-email-id-mentioned-in-column-A.html?anchorAnswerId=21093018#a21093018
ID: 21093018
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks a lot for the help...
This works perfect.
I think because my OS is Vista there may be some issue in registering.
The CDO worked great...
The duplicates are some issue when i type any comments or post new questions.
I have raised a post to the Technical department of EE for help.

Any help with the outher outlook posts...
This works perfect.
I think because my OS is Vista there may be some issue in registering.
The CDO worked great...
The duplicates are some issue when i type any comments or post new questions.
I have raised a post to the Technical department of EE for help.

Any help with the outher outlook posts...