[WIN32OLE] Outlook Automation Question

Discussion in 'Ruby' started by Steve Tuckner, Jun 26, 2003.

  1. This is a multi-part message in MIME format.

    ------=_NextPart_000_00BC_01C33BD1.368279B0
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit

    I am running a script to grab emails out of my Outlook email box. I want
    to grab ones that I have flagged and then I want to clear the flag
    however, the following code doesn't work. It seems to read the flag
    status just fine (it looks like 0 means no flag, 1 means cleared flag,
    and 2 means flagged). Any ideas?

    Steve Tuckner

    ------- Code -------------------

    outlook = WIN32OLE.new("Outlook.Application")
    namespace = outlook.GetNamespace("MAPI")

    class OutlookConst
    end

    WIN32OLE.const_load(outlook, OutlookConst)

    folder = namespace.GetDefaultFolder(OutlookConst::OlFolderInbox)

    i = 0
    folder.items.each do |item|
    if (item.FlagStatus == 2) then
    item.FlagStatus = 1
    end
    end


    ------=_NextPart_000_00BC_01C33BD1.368279B0
    Content-Type: text/html;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>



    <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
    <BODY>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial size=3D2>I am =
    running a=20
    script to grab emails out of my Outlook email box. I want to grab ones =
    that I=20
    have flagged and then I want to clear the flag however, the following =
    code=20
    doesn't work. It seems to read the flag status just fine (it looks like =
    0 means=20
    no flag, 1 means cleared flag, and 2 means flagged). Any=20
    ideas?</FONT></SPAN></DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial=20
    size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial size=3D2>Steve =

    Tuckner</FONT></SPAN></DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial=20
    size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial =
    size=3D2>------- Code=20
    -------------------</FONT></SPAN></DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial=20
    size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial =
    size=3D2>outlook =3D=20
    WIN32OLE.new("Outlook.Application")<BR>namespace =3D=20
    outlook.GetNamespace("MAPI")</FONT></SPAN></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial size=3D2>class =

    OutlookConst<BR>end</FONT></SPAN></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial=20
    size=3D2>WIN32OLE.const_load(outlook, OutlookConst)</FONT></SPAN></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial =
    size=3D2>folder =3D=20
    namespace.GetDefaultFolder(OutlookConst::OlFolderInbox)<BR></FONT></SPAN=
    ><FONT=20

    face=3DArial size=3D2></FONT></DIV>
    <DIV><SPAN class=3D537535015-26062003><FONT face=3DArial size=3D2>i =3D =

    0<BR>folder.items.each do |item|<BR>&nbsp;if (item.FlagStatus =3D=3D 2) =

    then<BR>&nbsp;&nbsp;item.FlagStatus =3D=20
    1<BR>&nbsp;end<BR>end<BR></FONT></SPAN></DIV></BODY></HTML>

    ------=_NextPart_000_00BC_01C33BD1.368279B0--
    Steve Tuckner, Jun 26, 2003
    #1
    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. apondu
    Replies:
    0
    Views:
    590
    apondu
    Jul 19, 2007
  2. Dave Burt
    Replies:
    0
    Views:
    253
    Dave Burt
    Mar 18, 2005
  3. Masaki Suketa
    Replies:
    4
    Views:
    374
    Dave Burt
    Mar 27, 2006
  4. Greg
    Replies:
    1
    Views:
    110
  5. zxem
    Replies:
    1
    Views:
    227
Loading...

Share This Page