phobia
Terugkerende gebruiker
- Lid geworden
- 4 sep 2006
- Berichten
- 1.777
Ik heb het volgende code gebouwd, maar nu wil ik dat de code gestopt word als er geen mailadres is ingevoerd.
Wie kan en wilt mij verder helpen?
Code:
Function SendEmail(aanEmailAdres As String, onderwerp As String, TekstHTML As String, Bijlage As String)
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
'==Onderwerp mail
objMessage.subject = onderwerp
'==Afzender mail
objMessage.From = """Paintball "" morphius.inc@upcmail.nl"
'==Ontvanger mail
objMessage.To = aanEmailAdres
'==Opzoeken van server gegevens.
server = Nz(DLookup("smtpserver", "tblServer"))
gebruiker = Nz(DLookup("gebruikersnaam", "tblServer"))
wachtwoord = Nz(DLookup("wachtwoord", "tblServer"))
'==Mail met HTML ody opmaken.
objMessage.HTMLBody = TekstHTML
'==Bijlage bij mail voegen.
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = server
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = gebruiker
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = wachtwoord
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
'==Mail verzenden.
objMessage.Send
Set objMessage = Nothing
'==Bericht dat mail verzonden is.
sErr = MsgBox("Verzonden aan " + aanEmailAdres, vbOKOnly, "Mail Verzonden.")
End Function
Wie kan en wilt mij verder helpen?