?

Log in

No account? Create an account
 

WebDAV / Exchange 2003 OWA / PHP - Web Developer

About WebDAV / Exchange 2003 OWA / PHP

Previous Entry WebDAV / Exchange 2003 OWA / PHP Dec. 19th, 2010 @ 05:37 pm Next Entry
There is very little reference for this anywhere on the internet that I can find. MSDN has the properties listed with what data type the property is expected to be.

I'm hoping someone here may be able to help? My head has been scratched.

My three main points of reference are:

    #    Content Classes                http://msdn.microsoft.com/en-us/library/aa486257%28v=EXCHG.65%29.aspx
    #    Content Classes:Message        http://msdn.microsoft.com/en-us/library/aa123730%28v=EXCHG.65%29.aspx
    #    Properties by Namespace        http://msdn.microsoft.com/en-us/library/aa486269%28v=EXCHG.65%29.aspx

I have also looked at the MAPI references.

Outgoing mail XML
<?xml version=\"1.0\"?>
<a:propertyupdate
    xmlns:a=\"DAV:\"
    xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\"
    xmlns:c=\"xml:\"
    xmlns:d=\"urn:schemas:mailheader:\"
    xmlns:e=\"urn:schemas:httpmail:\"
    xmlns:f=\"http://schemas.microsoft.com/mapi/proptag/\"
    xmlns:g=\"http://schemas.microsoft.com/mapi/\"
    xmlns:h=\"http://schemas.microsoft.com/exchange/\"
    xmlns:i=\"urn:schemas-microsoft-com:office:office\"
    xmlns:j=\"urn:schemas:calendar:\"
    xmlns:k=\"http://schemas.microsoft.com/repl/\"
    xmlns:l=\"urn:schemas-microsoft-com:exch-data:\"
    >
    <a:set>
        <a:prop>
            <a:contentclass>urn:content-classes:message</a:contentclass>
            <d:content-base>http://localhost/exchange/</d:content-base>
            <d:content-disposition>attachment; filename=test.txt</d:content-disposition>
            <h:outlookmessageclass>IPM.Note</h:outlookmessageclass>
            <h:autoaddsignature>1</h:autoaddsignature>
            <h:signaturehtml>2</h:signaturehtml>
            <h:signaturetext>3</h:signaturetext>
            <d:to>".$toEmail."</d:to>
            <e:subject>".$messageSubject."</e:subject>
            <e:htmldescription>Test email</e:htmldescription>
            <e:attachmentfilename>test.txt</e:attachmentfilename>
        </a:prop>
    </a:set>
</a:propertyupdate>

I cannot get the signature, nor the attachment to send. I have tried with/without content-base, content-disposition, attachmentfilename, signaturehtml, signaturetext and autoaddsignature in all combinations.

1. Is it possible to add signatures to outgoing messages through WebDAV with PHP? If so, how? I <i>could</i>] set the signatures up in my script, but I would like the user to be able to edit them via Outlook Web Access (OWA).

2. Is it possible to add attachment to outgoing messages through WebDAV with PHP? If so, how? A report will be generated before the mail functions are called. The report will be saved locally (e.g., http://localhost/report/2010-12-19.pdf) and not on the Exchange server (http://server.com/Exchange) -- I assume this is what content-base is for.

I know there are name spaces in the code that are unused. The emails send fine, but do not come with attachments or signatures.
Leave a comment
From:aeisor
Date:December 23rd, 2010 07:14 pm (UTC)
(Link)
Sorted, kind of. I can now send with attachments, but no signatures. I'll be putting together a few PHP libraries that I haven't seen elsewhere in the coming weeks if anyone is interested.
From:(Anonymous)
Date:June 7th, 2011 11:58 am (UTC)

Very interested

(Link)
Please don't hesitate to share what you came up with.

Cheers,
Patrik
From:aeisor
Date:June 7th, 2011 04:28 pm (UTC)

Re: Very interested

(Link)
If you're actually interested and not a spam bot, I'll post a link to something soon. I just need to change/remove some of the specific functionality I wrote into it for my ERP.
From:(Anonymous)
Date:February 16th, 2012 01:17 am (UTC)
(Link)
Can you please show how to sent the attachment? I managed to sent mail but without attachment.

Thank you.

chusoon
From:aeisor
Date:February 16th, 2012 07:13 am (UTC)
(Link)
1. Create the email message. Save it to the Drafts folder.
2. PUT file contents to Drafts/[subject of email.eml]/[filename]
3. Send email.

## Note, there are notes throughout this you need to read. There are also sections you need to change information on (ie- domain name, mailbox GLOBAL username / password). Please take the time to read and understand how this works, do not just copy and paste. ##

## Additional: The unread email function is fine for trawling through the inbox, junk and deleted items folders non-recursively. As soon as you put recursion on (see the $_SESSION variables in the code) it can start running horribly slow depending on the number of folders a user has. Querying my inbox over the internet on a 100KB uplink (server end) took about 15ms, recursive querying my inbox on the same link took over a minute as I have around 40 folders, each with several subfolders that have more subfolders. ##

Use the following as:

$variable=new exchangeMail([mailbox name]);

# If you do not use a global exchange user, you must set $variable->user="username"; and also change the $this->encrypted line to reflect the user password. I use a global exchange user, and do not log on to each account individually for my ERP.

$variable->create(
array(
"object_type"=>"message",
"header:to"=>"recipient.email@domain.com",
"httpmail:subject"=>"[enter subject]",
"httpmal:htmldescription"=>"[enter mail body here]"

)
); # This creates an email with a to, subject and body. There are other properties you can set such as importance, cc, bcc.

$variable->attach("[enter path to file here]","[enter friendly name you want displayed in the email]"); # You can use $variable->attach("folder23265256254/file24435637355.pdf","Your Invoice.pdf"); and this will rename the attachment from file24435637355.pdf to Your Invoice.pdf for the email.

$variable->send(); # Send the email.
From:aeisor
Date:February 16th, 2012 07:16 am (UTC)
(Link)
From:(Anonymous)
Date:February 17th, 2012 07:35 am (UTC)
(Link)
Dear aeisor:

Thank you for your file.

I did some charges for my system:
http://pastebin.com/66qnn4sE

May i know which version of exchange you using? mine one is 2003

And are you able to sent email in html format?

Thank you.
From:aeisor
Date:February 17th, 2012 09:27 pm (UTC)
(Link)
WebDAV is only available in Exchange 2003. Exchange 2007 and beyond use Exchange Web Services (a whole other ball game for PHP).

I haven't tried sending HTML emails. I'll take a look at your modified code below.
From:(Anonymous)
Date:February 17th, 2012 07:40 am (UTC)
(Link)
Dear Aeisor:

Thank for your file and i manage to send email with attachment.

I did some charges on the file for my side:
http://pastebin.com/xgQVAPyb


May i know which version of exchange you using now?

Are you able to sent html email?

Thank you.
chusoon
From:(Anonymous)
Date:February 17th, 2012 06:21 pm (UTC)
(Link)
Dear Aeisor:

Thanks for the scripts.

I managed to run well with some changes.
http://pastebin.com/qfBZJAVw


Are you able to sent html msg?

chusoon
From:(Anonymous)
Date:February 17th, 2012 08:55 pm (UTC)
(Link)
Dear Aeisor:

I managed to figure out for sending html email.

http://pastebin.com/Eqzp6tsb

Thank you.
chusoon
From:aeisor
Date:February 17th, 2012 09:35 pm (UTC)
(Link)
It looks as though you've changed variables for static information (ie- TANCHUSOON in the email name). What arguments are you passing when creating and sending? Can you supply an example?

What did you need to change to get HTML email working, if it didn't already?
From:(Anonymous)
Date:February 20th, 2012 01:37 am (UTC)
(Link)
Dear Aeisor:

Please find the latest scripts:
http://pastebin.com/5sifRzDr

Sorry, i forget to remove the static info:
$objectName=$folderName[$objectType].'/'.urlencode("".uniqid()."".'#'.date('YmdHis',time()).'#').'.EML';

If we using the subject text, we have to make sure that not xml key word in subject. If not, it will return error message.

To sent html email, we need to convert all applicable characters to HTML entities (Or maybe you can do this with subject)
foreach($array as $key => $value) { $this->xmlrequest.="<$key>".htmlentities($value).""; }

Thank you.
chusoon
From:(Anonymous)
Date:February 20th, 2012 01:53 am (UTC)
(Link)
Dear Aeisor:

Do you have any ideas how we can send mail through exchange server 2007 or 2010 or 2015?

Thank you.
chusoon
From:aeisor
Date:February 20th, 2012 06:55 am (UTC)
(Link)
Your best bet is to use the PHP EWS library (http://code.google.com/p/php-ews/source/browse/). I haven't touched EWS yet.
From:(Anonymous)
Date:February 24th, 2012 07:21 pm (UTC)
(Link)
Dear aeisor:

Sorry, i try to understand the script, but fail to get through.

Does the unread function just to count number of mail un-read? Does is possible to read the email content and the header?

Thank you.

chusoon
From:aeisor
Date:February 24th, 2012 08:04 pm (UTC)
(Link)
The unread function, as standard, reads the unread emails in the Inbox only. Using the $_SESSION variables it can be set to read Deleted Items, Junk Mail and/or recursively check folders (sub folders of Inbox, sub folders of those sub folders, etc...)

By selecting different fields in the SQL query you should be able to get the header and content of the messages too, as well as the sender, time/date, importance and more. That said, you may need to retrieve a list of unread emails and then iterate through them to retrieve the information you want.

Please post back if you get a working solution.

From:(Anonymous)
Date:March 5th, 2012 03:29 am (UTC)
(Link)
Dear Aeisor:

I managed to capture the email content and download the attachment.

Please the class below:
http://pastebin.com/5uK8NUQB

Thank you.
(Leave a comment)
Top of Page Powered by LiveJournal.com