access and email

Z

Zoki

Can anyone know how do I send email from access2000 without outlook or
outlook express?
 
R

Ron Weiner

If you clients have Win 2K or Higher OS then you can use CDO (Microsoft
Collaboration Data Objects) to sent the mail.

Public Sub testCDO()
' Purpose Send an Email with or without an attachment without using
Outlook or other MAPI client
' Uses Late Binding - Does not need a reference to the Microsoft
CDO For Windows library

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "YourMailServer.com"
'Only used if SMTP server requires Authentication
'.Item(strSch & "smtpauthenticate") = cdoBasic
'.Item(strSch & "sendusername") = "[email protected]"
'.Item(strSch & "sendpassword") = "YourPassword"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.FROM = "Ron"
.sender = "[email protected]"
.To = "[email protected]"
.Subject = "Sample CDO Message"
'.TextBody = "This is a test for CDO.message"
.HTMLBody = "this is not Bold But <B>This is!</B>"
'.AddAttachment "c:\Inv83595.pdf"
'.AddAttachment "c:\Inv83596.pdf"
'.MDNRequested = True
.Send

End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing
End Sub

Otherwise you have to install an ActiveX control and use that. You can find
a bunch of em here:
http://www.freedownloadscenter.com/Best/free-smtp-ocx.html

Ron W
www.WorksRite.com
 
S

Samantha

Ron,
I'm not exactly sure how your code works but it works!
My only question is how the following two lines of code works:
.FROM = "Ron"
.sender = "[email protected]"
Does it add the FROM and the SENDER together, i.e. in this case the receiver
would see the email as coming from [email protected]?

I put the my name as the FROM and tested. It seems to take the info at the
FROM string and add it to the the domain name.
thanks so much!
 
R

Ron Weiner

You can think of objCDOMessage.from as the Pretty name the reciepient will
see on the from line in the email, and objCDOMessage.sender as the mail
address that the reciepient will reply to should they choose to reply to the
email.
 
Top