Specify SMTP account when sending email through Outlook

G

Guest

Hi

I was wondering if it is possible to specify an SMTP account/service when
automating mail through Outlook using Access 2000. Most mail will be sent
via the default Microsoft Exchange server, but there are certain emails which
need to be routed through internet mail. I am using the standard code:

Function SendMessage(stAddr As String, stSubj As String, stBody As String,
Optional stCC As String, Optional stBCC As String, Optional AttachmentPath As
String) As Boolean

Set objOutlook = CreateObject("Outlook.Application")

Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

Set objOutlookRecip = .Recipients.Add(stRec)
objOutlookRecip.type = olTo

Set objOutlookAttach = .Attachments.Add(stPath)

......(etc)
.Send
End with

I can't see any place to specify the SMTP server - any ideas?

Many thanks.
 
G

Guest

Try using CDO. Something like

Dim imsg as CDO.Message
Dim iConf as CDO.Configuration
Dim flds as ADODB.Fields

Set iConf=imsg.configuration

Set Flds = iConf.Fields
Flds(cdoURLProxyServer) = "something.server.com:8080"
Flds(cdoURLProxyBypass) = "<local>"
Flds(cdoURLGetLatestVersion) = True
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "mymail"
Flds.Update

With iMsg
Set .Configuration = iConf
.CreateMHTMLBody (eAddress), cdoSuppressNone
.To ="(e-mail address removed)"
.From = "eFrom"
.Subject = "some subject"
.Send
End With
 
G

Guest

Thanks for the tip. I know very little about CDO and so will need to do some
research. Will this work with Exhange and Outlook 98?

Many thanks.

Ondine.
 
O

Ondine

Further to my last post, just to let you know I have set this up and it
works a dream. I can see that it will bypass Outlook and Exchange,
which is very useful.

Thanks very much for your help


Ondine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top