Partial Class cdosys Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Skapa CDOSYS objekt Dim ObjSendMail ObjSendMail = CreateObject("CDO.Message") Try ' Konfigurera SMTP-server inställningar ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' Skicka meddelandet via nätverk ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" ' Localhost ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False ' Användning av SSL? (True or False) ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 ' Användarnamn och lösenord för mailkontot ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "exempel@domän.se" ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "lösenord" ObjSendMail.Configuration.Fields.Update() ' Adressat ObjSendMail.To = "mottagare@domän.se" ObjSendMail.Subject = "Ämne för meddelande" ObjSendMail.From = "exempel@domän.se" ' Samma e-postadress som "sendusername" ' Format: HTML eller text (kommentera bort den ena) ' ObjSendMail.HTMLBody = "Huvudmeddelande" ObjSendMail.TextBody = "Huvudmeddelande" ObjSendMail.Send() ObjSendMail = Nothing Catch ex As Exception Finally ObjSendMail = Nothing End Try End Sub End Class