Specify SMTP account when sending email through Outlook


O

Ondine

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.
 
Ad

Advertisements

R

Ralph

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
 
O

Ondine

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.
 
Ad

Advertisements

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
 

Top