Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Automation (e-mail sending) - How to change default account?

Status
Not open for further replies.

jmjmjm

Programmer
Jul 19, 2004
17
0
0
ES
I am interested in being able to programmatically change
the default account of Outlook to send e-mails with different
POP servers depending on the sender of each e-mail (The
e-mails are stored in a table that contains the messages
of different senders.

Is there a way of doing it?

Thanks in advance.
 

Jose,

Sorry, I can't answer your question, except to say that I wanted to do this myself a few years ago, and eventually had to give up because I couldn't see any way of doing it.

But that was just because of my ignorance (I didn't know about Tek Tips then either). I hope someone can give you an answer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
With Rick Strahl's wwipstuff you can specify the SMTP server to use, so nothing to stop you from specifying a diffenrent one. You can also use CDO here is a sample.

Code:
Local iMsg,iConf
Declare SHORT InternetGetConnectedState In wininet.Dll;
    INTEGER @lpdwFlags, Integer dwReserved
lConnect=displayState()
If lConnect
    iMsg = Createobject("CDO.Message")
    iConf = Createobject("CDO.Configuration")
    Flds = iConf.Fields
    With Flds
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = 'Your SMTP server name here'
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
        .Update
    Endwith
    With iMsg
        .Configuration = iConf
        .To = "me@hotmail.com"
        .CC = ""
        .BCC = ""
        .From = "me@somewhere.com"
        .Subject = "Tis is a test"
        .TextBody = "Body of the message"
        .AddAttachment( "C:/" + lcFilename) &&  valid file
        .Send
    Endwith
    iMsg = .Null.
    iConf = .Null.
    wb = .Null.
Else
    Messagebox("Cannot send toe message, no internet connection")
Endif
Procedure  displayState
Local lConnected
lConnected = .F.
lpdwFlags = 0
If InternetGetConnectedState (@lpdwFlags, 0) = 1
    lConnected = .T.
Endif
Return lConnected
Endproc


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 

Sorry I meant to add the with MAPI you can logon to mapi with a different accounts as well. With Outlook, you can use different login accounts as well.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 

To complete my last statement look at the namespace.logon() method, that allows to specify any profiles you have access to.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top