[WIN32OLE] Outlook Automation Question

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default [WIN32OLE] Outlook Automation Question

    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::OlFolderI nbox)

    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::OlFolderI nbox)<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 Guest

  2. Similar Questions and Discussions

    1. Server side automation question
      I want to do some time based house cleaning chores on a server based on server time/date. I know how to do it based on a call from the client using...
    2. WIN32OLE question
      I'm using WIN32OLE with the Matrox ActiveMIL image processing library. For the most part things work fine but there's a function that won't work...
    3. Win32::OLE, Excel and OLE Automation question
      "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message news:<Xns93B9985BBBFFasu1cornelledu@132.236.56.8>... Thanks for the reply - I still got...
    4. OUTLOOK EXPRESS QUESTION: USERS
      I have Windows XP home edition. I use Outlook Express for my email. If I want to make a new user account, can I copy my email account in Outlook...
    5. ASP.NET & Outlook automation error
      I am trying to create an Outlook application object in my asp.net page, but i get a message saying it could not create instance of server. The...
  3. #2

    Default Re: [WIN32OLE] Outlook Automation Question

    Thanks, that worked great!
    > -----Original Message-----
    > From: Shashank Date [mailto:shanko_date@yahoo.com]
    > Sent: Thursday, June 26, 2003 4:34 PM
    > To: ruby-talk ML
    > Cc: [email]STUCKNER@MULTITECH.COM[/email]
    > Subject: Re: [WIN32OLE] Outlook Automation Question
    >
    >
    > > 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.
    >
    > [snip]
    >
    > That is because you are not "saving" the changes ;-)
    >
    > Try this:
    >
    > #---------------------------------------------------
    > require 'win32ole'
    >
    > outlook = WIN32OLE.new("Outlook.Application")
    > namespace = outlook.GetNamespace("MAPI")
    >
    > class OutlookConst
    > end
    >
    > WIN32OLE.const_load(outlook, OutlookConst)
    >
    > folder =
    > namespace.GetDefaultFolder(OutlookConst::OlFolderI nbox)
    >
    > i = 0
    > folder.items.each do |item|
    > if (item.FlagStatus == 2) then
    > item.FlagStatus = 1
    > item.Save
    > end
    > end
    > #---------------------------------------------------
    >
    > HTH,
    > -- shanko
    >
    >
    > __________________________________
    > Do you Yahoo!?
    > SBC Yahoo! DSL - Now only $29.95 per month!
    > [url]http://sbc.yahoo.com[/url]
    Steve Tuckner Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139