Link to home
Create AccountLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VB6 application to send Mail without Outlook

Is there a way to make a VB6 application send a mail without relying on Outlook.  I would like source code rather than components as I can't download freeware onto a production server.  I have something like this which works in ASP, but if you have something better please let me know.

Dim iMsg,objSendMail
Dim iConf
Dim Flds
Dim strNotes
Dim strSmartHost

Const cdoSendUsingPort = 1
StrSmartHost = "XXX"

Set objSendMail = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
 'set the CDOSYS configuration fields to use port 25 on the SMTP server
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
strnotes = strnotes & "<font color= red>" & "Project_Area: " & request.Form("Department")  & "<BR>"
strnotes = strnotes & "Other_Department: " & request.Form("Other_Department") & "<BR>"
strnotes = strnotes & "area: " & request.Form("area ")& "<BR>"
With objSendMail
    .From = "aa"
    .To = "BB"            
    .Subject = Request.Form("Subject") & " - " & Request.Form("Project_Title")
    .HTMLBody = strnotes
    .Send
End With
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of AlHal2

ASKER

Why wouldn't you embed it directly?
What I really mean to ask is whether you feel it's safe.
I prefer to keep it as a separate DLL that is easily re-usable accross different projects.

Also if you modify it, you recompile it, you re-deploy it and all your applications have access to the newer version.
Avatar of AlHal2

ASKER

Thanks.