Specify SMTP account when sending email through Outlook

Discussion in 'Microsoft Access VBA Modules' started by Guest, Sep 11, 2006.

  1. Guest

    Guest 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.
     
    Guest, Sep 11, 2006
    #1
    1. Advertisements

  2. Guest

    Guest 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 =""
    .From = "eFrom"
    .Subject = "some subject"
    .Send
    End With

    "Ondine" wrote:

    > 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.
    >
    >
    >
     
    Guest, Sep 12, 2006
    #2
    1. Advertisements

  3. Guest

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


    "Ralph" wrote:

    > 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 =""
    > .From = "eFrom"
    > .Subject = "some subject"
    > .Send
    > End With
    >
    > "Ondine" wrote:
    >
    > > 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.
    > >
    > >
    > >
     
    Guest, Sep 12, 2006
    #3
  4. Guest

    Ondine Guest

    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



    Ralph wrote:
    > 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 =""
    > .From = "eFrom"
    > .Subject = "some subject"
    > .Send
    > End With
    >
    > "Ondine" wrote:
    >
    > > 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.
    > >
    > >
    > >
     
    Ondine, Sep 13, 2006
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave

    sending email through Access through Notes

    Dave, Aug 4, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    290
  2. Guest

    Sending eMail using Outlook for specific email account

    Guest, Jun 19, 2005, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    227
    Guest
    Jun 19, 2005
  3. Guest

    Problem sending email through Outlook

    Guest, Apr 30, 2006, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    188
    Guest
    Sep 5, 2007
  4. Ian

    email through SMTP server

    Ian, Feb 9, 2009, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    143
    AlexM
    Feb 10, 2009
  5. lars

    Access 2007 stops working sending SMTP mails in Vista

    lars, Feb 11, 2009, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    319
Loading...

Share This Page