Some people I'm doing contract work for have provided me with the following as an e-mail script that works for them:
VB.NET code:
Public Sub SendMail(ByVal recip As String, ByVal sender As String, ByVal theMessage As String, ByVal theSubject As String, Optional ByVal carbonCopy As String = "", Optional ByVal blindCarbonCopy As String = "")
Const cdoSendUsingPickup = 1
Dim iMsg, iConf, Flds
iMsg = CreateObject("CDO.Message")
iConf = CreateObject("CDO.Configuration")
Flds = iConf.Fields
With Flds
.Item(" http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
.Update()
End With
With iMsg
.Configuration = iConf
.To = recip
.Cc = carbonCopy
.Bcc = blindCarbonCopy
.From = sender
.Subject = theSubject
.TextBody = theMessage
.Send()
End With
iMsg = Nothing
iConf = Nothing
Flds = Nothing
End Sub
I'm sure it'll work if I convert it to C# and add a CDO reference and all that jazz, but System.Net.Mail is there for a bloody reason.
Problem is, I don't know what the server address is. CDO clearly doesn't need one- is there any way I can get Net.Mail to do the same?