Programmer1974
Programmer
Hello all! I thought about posting this in the XML forumn, but after browsing through there, I think I might have better luck trying here first...
I'm creating my own custom components (.wsc extension) and have included a method where I want to make some of the parameters optional. Below is how I call the method and the component I created. This component is just for experimental purposes. It basically creates a CDO message and sends an e-mail via SMTP. As most of you know, the only required fields are the from and to addresses. I want to apply the same rules to my method. Here is how I call the method now:
Here is how I want to call the method:
Or even perhaps this:
Here is the component:
How can I modify my component to allow for optional parameters?
Thank you all for your help! If I don't have any luck here, I will try the XML forumn.
I'm creating my own custom components (.wsc extension) and have included a method where I want to make some of the parameters optional. Below is how I call the method and the component I created. This component is just for experimental purposes. It basically creates a CDO message and sends an e-mail via SMTP. As most of you know, the only required fields are the from and to addresses. I want to apply the same rules to my method. Here is how I call the method now:
Code:
Set objSMTP = CreateObject("SMTP")
strReturn = objSMTP.SendNote("test@email", "test@email", "", "", "Test subject", "Test message", "", "")
Code:
Set objSMTP = CreateObject("SMTP")
strReturn = objSMTP.SendNote("test@email", "test@email")
Code:
Set objSMTP = CreateObject("SMTP")
strReturn = objSMTP.SendNote("test@email", "test@email", , , "Test subject", "Test message")
Here is the component:
Code:
<package>
<?component error="true" debug="true"?>
<comment>
This component is used to send an e-mail via SMTP.
</comment>
<component id="SMTPEMail">
<object id="objEmail" progid="CDO.Message"/>
<registration
progid="SMTP"
description="This component sends an e-mail message via SMTP."
version="1.0"
clsid="{21D2D7E7-A67D-4B97-9F71-C027E173FC23}"/>
<public>
<method name="SendNote">
<parameter name="From" internalName="strFrom" />
<parameter name="To" internalName="strTo" />
<parameter name="CC" internalName="strCC" />
<parameter name="BCC" internalName="strBCC" />
<parameter name="Subject" internalName="strSubject" />
<parameter name="Body" internalName="strTextBody" />
<parameter name="HTMLBody" internalName="strHTMLBody" />
<parameter name="Attachments" internalName="strAttachments" />
</method>
</public>
<script language="VBScript">
Function SendNote(strFrom, strTo, strCC, strBCC, strSubject, strTextBody, strHTMLBody, strAttachments)
objEmail.From = strFrom
objEmail.To = strTo
objEmail.CC = strCC
objEmail.BCC = strBCC
objEmail.Subject = strSubject
If strTextBody > "" Then
objEmail.TextBody = strTextBody
Else
objEmail.HTMLBody = strHTMLBody
End If
If strAttachments > "" Then
objEmail.AddAttachment strAttachments
End If
objEmail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objEmail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "[SMTP server]"
objEmail.Configuration.Fields.Update
On Error Resume Next
objEmail.Send
SendNote = Err.Number
End Function
</script>
</component>
</package>
How can I modify my component to allow for optional parameters?
Thank you all for your help! If I don't have any luck here, I will try the XML forumn.