ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Private Sub SendMessage ... (https://www.excelbanter.com/excel-programming/336213-private-sub-sendmessage.html)

Chuckles123[_101_]

Private Sub SendMessage ...
 

Can you make the following code work?
I have tried it in a regular Module and in ThisWorkbook without eve
being able to 'single-step' thru the code.

Code:

'Sending SMTP mail via port 25 using CDOSYS
'This VBA sample uses CDOSYS to send SMTP mail using th
cdoSendUsingPort option and specifying a SMTP host.

'Note: It is recommended that all input parameters be validated whe
they are
'first obtained from the user or user interface.
'
Private Sub SendMessage(strTo As String, strFrom As String)

'Send using the Port on a SMTP server
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields

Set Flds = iConf.Fields

strTo = "mail address 2"
strFrom = "mail address 1"

With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "your e-mail server name or IP address"
'
??????????????????????????????
'Use SSL to connect to the SMTP server:
'.Item(cdoSMTPUseSSL) = True
.Item(cdoSMTPUseSSL) = False
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With

With iMsg
Set .Configuration = iConf
.To = strTo
.From = strFrom
.Subject = "This is a test CDOSYS message (Sent by Port 25)"
.TextBody = "This is the text body of the message..."
.Send
End With

'cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

End Sub

I believe that I have selected all of the appropriate Projec
References.

TIA,
Chuckles12

--
Chuckles12
-----------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...fo&userid=1494
View this thread: http://www.excelforum.com/showthread.php?threadid=39241



All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com