Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Use perl to create outlook .msg file

by aravinds (Initiate)
on Jan 07, 2012 at 03:24 UTC ( #946708=perlquestion: print w/ replies, xml ) Need Help??
aravinds has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I am using perl on windows and would like to know how to create an outlook email file (.msg)?

Essentially, what I need to create is a file exactly equal to one created by this process:
1. You compose an email in outlook
2. Add To, CC, Subject, HTML Body and do not send it yet but save it as a .msg file on hard-drive.
3. When you open the .msg file from your hard-drive, it automatically opens the email in edit mode and its ready for you to review/send.

Now, I have already written another perl program which auto generates the To,CC,Subject and HTML Body of the email. I need to know how to use PERL to create a .msg file with this information in it, on the hard-drive. I do not want PERL to actually send the message - it just has to create this editable .msg file.

The reason I don't want to send the email but rather create a .msg file is because the system in which these perl programs run does not have outlook configured (cannot be configured due to firewall/designed to not be able to access Exchange Server, although Outlook is installed on this system) and therefore I need PERL to just create the .msg file which I can copy over to another system where I can just open it in Outlook installed there and review it/send it.

I have already looked at other Outlook related posts in perlmonks but did not find one dealing with just creating a msg file as opposed to actually sending the email.

Appreciate if you can help

Thanks

Comment on Use perl to create outlook .msg file
Replies are listed 'Best First'.
Re: Use perl to create outlook .msg file
by Anonymous Monk on Jan 07, 2012 at 03:53 UTC
      Hi Anonymous Monk,

      Thanks for your time.

      $message->save; saves it in the Drafts folder within Outlook, but I need the program to create a file on the harddrive as a physical file (.msg).

      Did not find any useful code snippets on the duckduckgo search engine either.
        The solution is: $message->SaveAs('C:\test.msg');

        Um, go to MSDN, find the message object , look for save, save_to, etc, etc

      I tried this, but it seems to my situation that I cannot create $outlook = new Mail::Outlook()... it always return undef... I don't know why... I have outlook 2007 and installed the perl module Email-Outlook
        You have commented on an old node, anonymously. Get a login, it's cheap, and then you can search more easily for your own posts, and get /msgs.

        You would do better to start a new post, referencing this thread, and show the code you used (see How do I post a question effectively?).

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://946708]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-08-01 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found
    past polls