Skip to content

Instantly share code, notes, and snippets.

@mitaken
Created July 20, 2015 14:46
Show Gist options
  • Save mitaken/98f93a8e23eba9258665 to your computer and use it in GitHub Desktop.
Save mitaken/98f93a8e23eba9258665 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="Shift_JIS"?>
<package>
<?component error="true" debug="true"?>
<component id="Mitaken.Mail">
<!-- SMTP Configuration -->
<resource id="SMTP_HOST">[email protected]</resource>
<resource id="SMTP_PORT">25</resource>
<resource id="SMTP_FROM">[email protected]</resource>
<resource id="SMTP_USER"></resource>
<resource id="SMTP_PASS"></resource>
<!-- COM Registration Name -->
<registration progid="Mitaken.Mail" version="1.0"/>
<!-- Public Methods, Properties and Events -->
<public>
<method name="_NewEnum" dispid="-4"/>
<property name="Message">
<get/>
</property>
</public>
<!-- Reference CDO.Configuration for Constants -->
<reference object="CDO.Configuration"/>
<!-- Create CDO.Message instance -->
<object id="objMessage" progid="CDO.Message"/>
<script language="VBScript">
<![CDATA[
Option Explicit
'Setup SMTP Configuration
'https://msdn.microsoft.com/en-us/library/ms872853(v=exchg.65).aspx
With objMessage.Configuration.Fields
'The Domain Name System (DNS) or Network Basic Input/Output System (NetBIOS) name of the host to which to post messages using the SMTP protocol.
.Item(cdoSMTPServer) = getResource("SMTP_HOST")
'The port on which the SMTP service specified by the smtpserver field is listening for connections.
.Item(cdoSMTPServerPort) = getResource("SMTP_PORT")
'The mechanism to use to send messages.
.Item(cdoSendUsingMethod) = CdoSendUsing.cdoSendUsingPort
'Indicates that Secure Sockets Layer (SSL) should be used when sending messages using the SMTP protocol over the network.
.Item(cdoSMTPUseSSL) = True
'Indicates the number of seconds to wait for a valid socket to be established with the SMTP service before timing out.
.Item(cdoSMTPConnectionTimeout) = 10
'SMTP Authentification
If Not IsNull(getResource("SMTP_USER")) And Not IsNull(getResource("SMTP_PASS")) Then
'Specifies the authentication mechanism to use when authentication is required to send messages to an SMTP service using a TCP/IP network socket.
.Item(cdoSMTPAuthenticate) = CdoProtocolsAuthentication.cdoBasic
'The username for authenticating to an SMTP server using basic (clear-text) authentication.
.Item(cdoSendUserName) = getResource("SMTP_USER")
'The password used in conjunction with the sendusername field when authenticating to a SMTP or Microsoft Exchange WebDAV service over the network.
.Item(cdoSendPassword) = getResource("SMTP_PASS")
Else
'Specifies the authentication mechanism to use when authentication is required to send messages to an SMTP service using a TCP/IP network socket.
.Item(cdoSMTPAuthenticate) = CdoProtocolsAuthentication.cdoAnonymous
End If
'Apply Configuration
.Update
End With
'Get CDO.Message
Function get_Message()
'Set default From
objMessage.From = getResource("SMTP_FROM")
Set get_Message = objMessage
End Function
'Get CDO.Configuration
Function [_NewEnum]()
Set [_NewEnum] = objMessage.Configuration.Fields.[_NewEnum]
End Function
]]>
</script>
</component>
</package>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment