[AccessD] Need SMTP Code

Fred Hooper fahooper at trapo.com
Sun Aug 5 10:56:04 CDT 2007


Rocky:

I use the code on W2K servers (with and without Office installed) and XP
pc's, haven't tried it on Vista. BTW, the
"http://schemas.microsoft.com/cdo/configuration/smtpserver" does *not*
contact Microsoft, which I determined when a client was concerned.

A Google search on "cdo -debt -chromo Microsoft" got some interesting hits.

Fred

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
Beach Access Software
Sent: Sunday, August 05, 2007 9:33 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Need SMTP Code

Fred:

Seems too easy. :)  CDO is a standard part of Windows?  Or Access?

Thanks and regards,

Rocky
 




 	
	

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Fred Hooper
Sent: Sunday, August 05, 2007 5:36 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Need SMTP Code

 

I've used the code below in many places.

 

Fred

 

Public Sub SendEmail(strFrom As String, strTo As String, strSubject As
String, strMessage As String)

    Dim objEmail As Object

    Dim objMsg As Object

    Dim objConf As Object

    Dim Flds As Variant

    

    Set objMsg = CreateObject("cdo.message")

    Set objConf = CreateObject("cdo.configuration")

    

    Set Flds = objConf.Fields

    With Flds

        ' The first item with value "2" indicates that smpt is not installed
on this machine

        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =
2

        ' Next item is the name of the smpt server to use.

        ' Look in Outlook | Tools | Email Accounts | View or change... |
Change to find

        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"yourmailhost.com"

        ' This is the port the smpt server uses, 25 is the default

 
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 25

        .Update

    End With

    

    With objMsg

        Set .configuration = objConf

            .To = strTo

            .from = strFrom

            .Subject = strSubject

            .Textbody = strMessage

            ' It doesn't work with more than one attachment

'            .AddAttachment "c:\readme.txt"

            .Fields.Update

            .Send

    End With

    

    Set objMsg = Nothing

    Set objConf = Nothing

End Sub

 

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
Beach Access Software
Sent: Saturday, August 04, 2007 9:10 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Need SMTP Code

 

Dear List:

 

 

I have a lot of Access sites bookmarked but can never find what I need in

them.  I'm looking for some code to handle email from Access using SMTP.

Does anyone know if there's a module I can crib from one of the many Access

sites?

 

MTIA

 

Rocky

 

-- 

AccessD mailing list

AccessD at databaseadvisors.com

http://databaseadvisors.com/mailman/listinfo/accessd

Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.4/936 - Release Date: 8/4/2007
2:42 PM
 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list