Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Pipe email to application on Windows

  • 09-10-2008 3:00pm
    #1
    Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭


    I want to get an email piped to an application on a windows 2003 server (Plesk installed). Is this possible? I was told my my VPS admins that it isn't, but come on! it's gotta be.

    Anyone have any ideas?


Comments

  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    No one know how to do this?

    What about an Outlook script to pass on the email? Is it possible to do a POST from an Outlook script?


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    You can always use VBS to send email using MAPI

    Or do you want to send an email to your application?

    Otherwise, you can always have a quick and dirty service that just saves the email to a location that you can parse it.


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    I want to sent it to an application. Saving to disk will work. Do you happen to know how to do this in a macro? I have managed to save the attachments to disk, but can't work out how to save the contents.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Item.SaveAs "c:\test.msg", olMSG within Outlook or where you can reference the Outlook DLL (early binding)

    Otherwise if you are using late binding (creating the object from the type name) use the value 3 for olMsg or define olMSG as 3

    Sample

    http://cwashington.netreach.net/depo/view.asp?Index=948

    Gives you an idea on how to save the file to the hard disk


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    Thanks Ginger.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Do this as a .NET service with the interop classes and you can log into a mail box and save the files to your hard disk and then get your progam to pick it up ..

    Or else if you have control over the programs code, create a mailbox for it and get it to log into its own mailbox and get the data that way.


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    Cool, got it.
    Thanks.
    using System;
    using Microsoft.Office.Interop.Outlook;
    
    namespace Office
    {
        class Program
        {
            static void Main(string[] args)
            {
                Microsoft.Office.Interop.Outlook.Application app = null;
                Microsoft.Office.Interop.Outlook._NameSpace ns = null;
                Microsoft.Office.Interop.Outlook.MailItem item = null;
                Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
                Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;
    
                try 
                {
                      app = new Microsoft.Office.Interop.Outlook.Application();
                      ns = app.GetNamespace("MAPI");
                      ns.Logon(null,null,false, false);
    
                      inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                      subFolder = inboxFolder.Folders["Test"]; //folder.Folders[1]; also works
                      Console.WriteLine("Folder Name: {0}, EntryId: {1}", subFolder.Name, subFolder.EntryID);
                      Console.WriteLine("Num Items: {0}", subFolder.Items.Count.ToString());
    
                          for(int i=1;i<=subFolder.Items.Count;i++)
                          {                 
                              item = (Microsoft.Office.Interop.Outlook.MailItem)subFolder.Items[i];
                              Console.WriteLine("Item: {0}", i.ToString());
                            Console.WriteLine("Subject: {0}", item.Subject);
                            Console.WriteLine("Sent: {0} {1}", item.SentOn.ToLongDateString(), item.SentOn.ToLongTimeString());
                            Console.WriteLine("Categories: {0}", item.Categories);
                            Console.WriteLine("Body: {0}", item.Body);
                            Console.WriteLine("HTMLBody: {0}", item.HTMLBody);
                          }
                        }
                        catch (System.Runtime.InteropServices.COMException ex)
                        {
                          Console.WriteLine(ex.ToString());
                        }
                        finally
                        {
                          ns = null;
                          app = null;
                          inboxFolder = null;
                        }
            }
        }
    }
    

    modified from http://geekswithblogs.net/timh/archive/2006/05/26/79720.aspx


Advertisement