...

View Full Version : 'SendEmail' Error



wolvo2741
11-05-2009, 11:44 AM
Hi all, Could some one please help me with my problem i get
"error wrong number of arguments or invalid property assignment 'SendEmail'"
I am building a fault logger for a large network to report faults.

Please help me with this, I have got this far with the coding now i am stuck
Please help.


<HEAD>
<TITLE>Connect2Truth Fault Logger</TITLE>
<HTA:APPLICATION ID="oUserManager"
APPLICATIONNAME="User Management"
BORDER="fixed"
CAPTION="yes"
ICON=".\ConnectLogo.ico"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">

<style type="text/css">
body { font-family: tahoma,arial;
}

textbox { font-family: tahoma,arial;
}

.page_header { background: blue;
font-size: 14pt;
color: white;
padding: 10px;
position: absolute;
top:0px;
left:0px;
width:100%
}

.page_footer { text-align: right;
background: blue;
font-size: 14pt;
color: white;
padding: 10px;
}

.input_box { border: thin dotted black;
padding: 10px;
}

.information { border: thin dotted black;
padding: 10px;
}

.wrapper { padding: 10px;
}


</style>

<script type="text/vbscript">

sub getUsername()

Set objWshNet = CreateObject("Wscript.Network")
strCN = lcase(objWshNet.ComputerName)
strUN = lcase(objWshNet.UserName)

Fault_rep_By.Value = strUN & " on " & strCN

end sub

sub sendFaultReps()

EmailSubject = "Fault Report : " & Fault_rep_PC.value

EmailContentsFriendly = "This is a system generated email send from the Connect2Group Fault Reporting system." & vbCrLf & vbCrLf & "A fault has been reported on the system: " & Fault_rep_PC.value & " the message below contains details of the fault:" & vbCrLf & vbCrLf & Fault_rep_Problem.value
EmailContentsSystem = Fault_rep_Problem.value

'Send the Helpdesk Email
SendEmail EmailSubject, "fault@connect2group.com", EmailContentsSystem

'Send Friendly Emails
SendEmail EmailSubject, "tyrone2741@btinternet.com", EmailContentsFriendly

msgbox "Your fault report has been submitted and will be delt with by the Connect2Group Fault dept."

End Sub

Function sendEmail(eSubject, eFrom, eTo, eTextBody)

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Trim(esubject)
objMessage.From = Trim(eFrom)
objMessage.To = Trim(eTo)
objMessage.TextBody = Trim(eTextBody)

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.connect2group.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 26
objMessage.Configuration.Fields.Update

objMessage.Send

End Function

</script>
<script language=javascript type='text/javascript'>
function hidediv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){//if they are 'see' divs
if (document.getElementById) // DOM3 = IE5, NS6
divs[i].style.display="none";// show/hide
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'hidden';
else // IE 4
document.all.hideShow.divs[i].style.display = 'none';
}
}
}

function showdiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){
if (document.getElementById)
divs[i].style.display="";
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'visible';
else // IE 4
document.all.hideShow.divs[i].visibility = 'visible';
}
}
}

function select_tab(i) {

hidediv('user_info')
hidediv('user_contact')
hidediv('user_profile')
hidediv('user_trouble')
hidediv('user_actions')


showdiv(i)
}
</script>


</HEAD>

<BODY onLoad="getUsername()">

<div class="page_header">
Connect2Truth Fault Report System
</div>

<br /><br />

<table width="559">
<tr><td valign="top" width="98">Computer ID:</td><td width="451"><input type="text" name="Fault_rep_PC" size=30 /><i>e.g.
Name-Location/OS</i></td></tr>
<tr><td valign="top" width="98">Problem:</td><td width="451"><textarea name="Fault_rep_Problem" rows=10 cols=50></textarea></td></tr>
<tr><td valign="top" width="98">Reported by:</td><td width="451"><input readonly type="text" name="Fault_rep_By" size=30/>
(Username &amp; Computer Name)</td></tr>
</table>

<br />

<div class="page_footer">
<input type="button" value="Submit" onClick="sendFaultReps()"/>
</div>

<p>If there is a problem with the Fault Logger Click
<a href="mailto:loggerapp@connect2group.com?subject=Error with the Fault logger(Urgent)">
here</a></p>
<p><span style="position: absolute; left: 700; top: 103">
<img border="0" src="Connect2TruthLogo.gif" width="120" height="100"></span></p>

</BODY>
</HTML>

SB65
11-05-2009, 04:15 PM
From a very cursory glance at this your sendEmail function requires four arguments:


Function sendEmail(eSubject, eFrom, eTo, eTextBody)

but in your code you are only providing three, and, unless I've forgotten how VB works, not calling the function correctly - no "eTo", no brackets:


SendEmail EmailSubject, "fault@connect2group.com", EmailContentsSystem

The error message is pretty much telling you this.

wolvo2741
11-05-2009, 07:57 PM
Thanks for your reply, I will make the changes that other sites have suggested and thanks I am quite new to coding, this was a project for me to improve my coding skills.

with thanks

wolvo2741
11-05-2009, 09:01 PM
This is probs an easy problem for most of you, but I would really appreciate help

I am getting error at least one of the From or Sender fields is required, but neither was found.


<HEAD>
<TITLE>Connect2Truth Fault Logger</TITLE>
<HTA:APPLICATION ID="oUserManager"
APPLICATIONNAME="User Management"
BORDER="fixed"
CAPTION="yes"
ICON=".\ConnectLogo.ico"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal">

<style type="text/css">
body { font-family: tahoma,arial;
}

textbox { font-family: tahoma,arial;
}

.page_header { background: blue;
font-size: 14pt;
color: white;
padding: 10px;
position: absolute;
top:0px;
left:0px;
width:100%
}

.page_footer { text-align: right;
background: blue;
font-size: 14pt;
color: white;
padding: 10px;
}

.input_box { border: thin dotted black;
padding: 10px;
}

.information { border: thin dotted black;
padding: 10px;
}

.wrapper { padding: 10px;
}


</style>

<script type="text/vbscript">

sub getUsername()

Set objWshNet = CreateObject("Wscript.Network")
strCN = lcase(objWshNet.ComputerName)
strUN = lcase(objWshNet.UserName)

Fault_rep_By.Value = strUN & " on " & strCN

end sub

sub sendFaultReps()

EmailSubject = "Fault Report : " & Fault_rep_PC.value

EmailContentsFriendly = "This is a system generated email send from the Connect2Group Fault Reporting system." & vbCrLf & vbCrLf & "A fault has been reported on the system: " & Fault_rep_PC.value & " the message below contains details of the fault:" & vbCrLf & vbCrLf & Fault_rep_Problem.value
EmailContentsSystem = Fault_rep_Problem.value

'Send the Helpdesk Email
SendEmail EmailSubject, eTo, "fault@connect2group.com", EmailContentsSystem

'Send Friendly Emails
SendEmail EmailSubject, "tyrone2741@btinternet.com", EmailContentsFriendly

msgbox "Your fault report has been submitted and will be delt with by the Connect2Group Fault dept."

End Sub

Function sendEmail(eSubject, eFrom, eTo, eTextBody)

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Trim(esubject)
objMessage.From = Trim(eFrom)
objMessage.To = Trim(eTo)
objMessage.TextBody = Trim(eTextBody)

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.connect2group.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 26
objMessage.Configuration.Fields.Update

objMessage.Send

End Function

</script>
<script language=javascript type='text/javascript'>
function hidediv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){//if they are 'see' divs
if (document.getElementById) // DOM3 = IE5, NS6
divs[i].style.display="none";// show/hide
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'hidden';
else // IE 4
document.all.hideShow.divs[i].style.display = 'none';
}
}
}

function showdiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){
if (document.getElementById)
divs[i].style.display="";
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'visible';
else // IE 4
document.all.hideShow.divs[i].visibility = 'visible';
}
}
}

function select_tab(i) {

hidediv('user_info')
hidediv('user_contact')
hidediv('user_profile')
hidediv('user_trouble')
hidediv('user_actions')


showdiv(i)
}
</script>


</HEAD>

<BODY onLoad="getUsername()">

<div class="page_header">
Connect2Truth Fault Report System
</div>

<br /><br />

<table width="559">
<tr><td valign="top" width="98">Computer ID:</td><td width="451"><input type="text" name="Fault_rep_PC" size=30 /><i>e.g.
Name-Location/OS</i></td></tr>
<tr><td valign="top" width="98">Problem:</td><td width="451"><textarea name="Fault_rep_Problem" rows=10 cols=50></textarea></td></tr>
<tr><td valign="top" width="98">Reported by:</td><td width="451"><input readonly type="text" name="Fault_rep_By" size=30/>
(Username &amp; Computer Name)</td></tr>
</table>

<br />

<div class="page_footer">
<input type="button" value="Submit" onClick="sendFaultReps()"/>
</div>

<p>If there is a problem with the Fault Logger Click
<a href="mailto:tyrone2741@btinternet.com?subject=Error with the Fault log(Urgent)">
here</a></p>
<p><span style="position: absolute; left: 700; top: 103">
<img border="0" src="Connect2TruthLogo.gif" width="120" height="100"></span></p>

</BODY>
</HTML>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum