Outlook, MAPI, Sending Mail

Discussion in 'Ruby' started by Jade Tucker, Aug 18, 2008.

  1. Jade Tucker

    Jade Tucker Guest

    Hi All,

    I am trying to write a program to test that our email servers are
    working properly.

    I have a ruby program to send an email from a MS Outlook inbox connected
    to an exchange mail server. The program using WIN32OLE to connect to
    Outlook. The program sends an email to another email account (out of
    our network) that is setup to automatically send back the email. My
    program then waits for the email to return for a max of 5 minutes before
    it will fail.

    The first issue I encountered was Outlook poping up a dialog box warning
    me that a program was trying to send an email on my behalf. With
    Outlook 2007 I was able to disable this security restriction.

    This program needs to run on a server without anyone logged in. For
    some reason this is not working as a scheduled task set to run under the
    user the email account is setup for.

    I am looking for any help or advice on how to get this working. I am
    getting frustrated with developing applications that run fine normaly,
    but as soon as I try to run them on a schedule or invoked remotely they
    start breaking.

    Does anyone know of a better way to do this or can help me with my
    problem?

    Thanks,
    JT
    --
    Posted via http://www.ruby-forum.com/.
     
    Jade Tucker, Aug 18, 2008
    #1
    1. Advertising

  2. Jade Tucker

    Jeff Miller Guest

    Jade Tucker wrote:
    > Hi All,
    >

    Hey there,
    I had to develop an application that had to interact with Outlook quite
    a bit - however, I recommend that you use MAPI/CDO via the Exchange side
    rather than through client-side outlook, since you have less
    dependencies and a less likely chance of it breaking. Check out some VB
    examples from CDOlive.com and outlookcode.com . There is great help
    there.

    Good luck,
    - Jeff Miller

    > I am trying to write a program to test that our email servers are
    > working properly.
    >
    > I have a ruby program to send an email from a MS Outlook inbox connected
    > to an exchange mail server. The program using WIN32OLE to connect to
    > Outlook. The program sends an email to another email account (out of
    > our network) that is setup to automatically send back the email. My
    > program then waits for the email to return for a max of 5 minutes before
    > it will fail.
    >
    > The first issue I encountered was Outlook poping up a dialog box warning
    > me that a program was trying to send an email on my behalf. With
    > Outlook 2007 I was able to disable this security restriction.
    >
    > This program needs to run on a server without anyone logged in. For
    > some reason this is not working as a scheduled task set to run under the
    > user the email account is setup for.
    >
    > I am looking for any help or advice on how to get this working. I am
    > getting frustrated with developing applications that run fine normaly,
    > but as soon as I try to run them on a schedule or invoked remotely they
    > start breaking.
    >
    > Does anyone know of a better way to do this or can help me with my
    > problem?
    >
    > Thanks,
    > JT


    --
    Posted via http://www.ruby-forum.com/.
     
    Jeff Miller, Aug 19, 2008
    #2
    1. Advertising

  3. RnJvbTogSmFkZSBUdWNrZXIgW21haWx0bzpqdHVja2VyQHhvamV0LmNvbV0gDQojIEkgYW0gdHJ5
    aW5nIHRvIHdyaXRlIGEgcHJvZ3JhbSB0byB0ZXN0IHRoYXQgb3VyIGVtYWlsIHNlcnZlcnMgYXJl
    DQojIHdvcmtpbmcgcHJvcGVybHkuIEkgaGF2ZSBhIHJ1YnkgcHJvZ3JhbSB0byBzZW5kIGFuIGVt
    YWlsIGZyb20gYSBNUw0KIyBPdXRsb29rIGluYm94IGNvbm5lY3RlZCB0byBhbiBleGNoYW5nZSBt
    YWlsIHNlcnZlci4gIFRoZSBwcm9ncmFtIHVzaW5nIA0KDQpqdXN0IHVzZSBydWJ5J3MgbmV0L3Nt
    dHAgYW5kIHlvdXIgZmluZS4gaW4gZmFjdCwgc2luY2UgeW91J3JlIGNvZGluZyBpdCwgeW91IGNh
    biBkbyBhIG1vcmUgZ3JhbnVsYXIgY2hlY2tpbmcgb2YgeW91ciBzZXJ2ZXJzIGJ5DQoNCmEuIGNo
    ZWNraW5nIGNvbm5lY3Rpb24gdGhydSBwaW5nDQpiLiBjaGVja2luZyBzZXJ2aWNlIHRocnUgcG9y
    dCAyNQ0KYy4gY2hlY2tpbmcgZW1haWwgZnhuYWxpdHkgYnkgc2VuZGluZyBhbiBlbWFpbC4gZm9y
    IGEgc2FtcGxlLCBzZWUgbXkgbGFzdCBwb3N0IGhlcmUgaHR0cDovL2dyb3Vwcy5nb29nbGUuY29t
    L2dyb3VwL3J1YnktdGFsay1nb29nbGUvYnJvd3NlX3RocmVhZC90aHJlYWQvOTU3ZGM1YTNiMTcz
    ODlhYw0KDQpraW5kIHJlZ2FyZHMgLWJvdHANCg0KDQoNCg0KDQo=
     
    Peña, Botp, Aug 19, 2008
    #3
  4. Jade Tucker

    Glen Holcomb Guest

    On Tue, Aug 19, 2008 at 4:28 AM, Pe=F1a, Botp <> wrot=
    e:

    > From: Jade Tucker [mailto:]
    > # I am trying to write a program to test that our email servers are
    > # working properly. I have a ruby program to send an email from a MS
    > # Outlook inbox connected to an exchange mail server. The program using
    >
    > just use ruby's net/smtp and your fine. in fact, since you're coding it,
    > you can do a more granular checking of your servers by
    >
    > a. checking connection thru ping
    > b. checking service thru port 25
    > c. checking email fxnality by sending an email. for a sample, see my last
    > post here
    > http://groups.google.com/group/ruby-talk-google/browse_thread/thread/957d=

    c5a3b17389ac
    >
    > kind regards -botp
    >
    >
    >
    >
    >
    >

    Small qualifier here. Outlook doesn't always do SMTP, it can be turned off
    by the more Evangelical MS Admins.

    --=20
    "Hey brother Christian with your high and mighty errand, Your actions speak
    so loud, I can't hear a word you're saying."

    -Greg Graffin (Bad Religion)
     
    Glen Holcomb, Aug 19, 2008
    #4
  5. Jade Tucker

    Jade Tucker Guest

    Glen Holcomb wrote:
    > On Tue, Aug 19, 2008 at 4:28 AM, Peña, Botp <>
    > wrote:
    >
    >> c. checking email fxnality by sending an email. for a sample, see my last
    >> post here
    >> http://groups.google.com/group/ruby-talk-google/browse_thread/thread/957dc5a3b17389ac
    >>
    >> kind regards -botp
    >>
    >>
    >>
    >>
    >>
    >>

    > Small qualifier here. Outlook doesn't always do SMTP, it can be turned
    > off
    > by the more Evangelical MS Admins.
    >
    > --
    > "Hey brother Christian with your high and mighty errand, Your actions
    > speak
    > so loud, I can't hear a word you're saying."
    >
    > -Greg Graffin (Bad Religion)


    Thanks for the tips. But yeah, I can't test with SMTP and I already
    have another app to do ping tests on all of our servers.

    UPDATE-- I got the app to work. I had to end up using Outlook 2003 on
    the server. I had to use a plugin (forgot the name but i can get it) to
    modify the security settings in '03 so that it doesn't keep asking me to
    allow the message to be sent. Part of my problem was that the Outlook
    app wanted my password everytime it tried to send an email. I just
    checked the box to remember the password.

    Also, to anyone programming something that sends an email with outlook
    03, you have to use the SyncObjects method after using message.Send or
    else it will just put it in your outbox and not send the message. It
    doesn't seem to do this in '07. Also, 07 provides the ole method
    SendAndRecieve.

    Here is a little code to clarify:

    require 'win32ole'

    @outlook = WIN32OLE.new('Outlook.Application')
    @mapi = @outlook.GetNameSpace('MAPI')

    message = @outlook.createItem(0)
    message.subject('some subject')
    ...
    message.Save
    message.Send

    @mapi.SyncObjects #OR with '07 @mapi.SendAndRecieve


    --
    Posted via http://www.ruby-forum.com/.
     
    Jade Tucker, Aug 19, 2008
    #5
    1. Advertising

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. Kevin Quigley

    Sending mail using MAPI

    Kevin Quigley, Feb 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    656
    Kevin Quigley
    Feb 26, 2004
  2. Nick Gilbert
    Replies:
    1
    Views:
    2,889
    Elton Wang
    Apr 6, 2005
  3. David Fraser

    Sending Mail via Extended MAPI

    David Fraser, Jul 30, 2004, in forum: Python
    Replies:
    4
    Views:
    1,010
    David Fraser
    Aug 6, 2004
  4. Replies:
    0
    Views:
    1,415
  5. Replies:
    2
    Views:
    1,023
    A. Sinan Unur
    May 25, 2006
Loading...

Share This Page