Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Location
    France
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to get an email GUID with PHP

    Hi Everyone,

    I am trying to incorporate into my existing PHP script to retrieve the "GUID" (as it is called by MS - Globally unique identifier) for email messages downloaded with the php imap functions.

    According to what I understand (and have read) the GUID of the message does not change wherever it is moved, thus if I can retrieve this ID, I could theoretically create a link in my Web page that would link to the original message (outlook:\\xxxxx type link), no matter where the message is stored.

    Let me explain a bit more what is happening today.
    1. We connect to the exchange server and download the message
    2. We save the message and its parts/detail in a MySQL database
    3. We display to the user in a web page the email details The user can respond to the message via his/her interface (plain text email only).

    What we want to do now is to give the user a hyper-link in his/her interface that will open the original message so that he can reply with MS Outlook if he wants to make an HTML email (the standard interface only makes Text emails).

    Today I have made the code to generate a link that works to open the message, but the problem is that i use the message "subject" field to find it, and if we have more than 1 email with the same subject, it only opens the last message in the folder. For example:

    The link I create looks something like this:
    <a href ='outlook:\\Public%20Folders\All%20Public%20Folders\Shared%20Support%20Folder\~Email%20Subject'>Orig inal email</a>
    This link works to get to the email in our public folder, but if i have more than 1 email with the subject "Email Subject" the link calls the newest one. The only way (from what I can understand in documentation I have read) to overcome this is to use a links such as this:

    <a href ='outlook:GUID'>Original email</a>
    My questions are:
    1. Where is the GUID for an email message stored?
    2. How can I retrieve the GUID with PHP (I tried to use the imap_uid() function but this returns a 4 digit number, which is not the same as GUID)
    3. If this is not possible ... has anybody tried to do the same in another way?

    Thank you in advance for any ideas and experiences shared.

    Best regards

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    E-mails don't have a GUID. They have the Message-Id: header, found in the e-mail header. Theoretically it should have the same functionality as a GUID, (to be globally unique), but the way some client programmes generate the id... Anyhows, view the e-mail in a text editor or set your e-mail client to display all headers. You'll see it then. The best way to create the links is to scan the directory and link to the files. The client should be saving each e-mail with a unique filename, if you're using the likes of IMAP. If using POP3 or that crap Outlook calls a DB for storage, use the message id.
    Last edited by MattF; 11-23-2010 at 10:01 AM.

  • Users who have thanked MattF for this post:

    nicdev007 (11-23-2010)

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Location
    France
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi MattF,

    Thanks for the helpful reply. I have a debug file where I dump the header and the values from the imap_fetchheader() function, but the field "Message-ID:" is always empty?? I am not sure what I am doing wrong...

    The idea behind this type of link came from a program called 'Linker', which allows you to (via GUI) create a hyperlink to a message/folder, and the using that in a document so that others can view the email. So for example i can create a link to our Shared public folder that looks like this:

    <a href='Outlook:000000001A447390AA6611CD9BC800AA002FC45A0380AD1293A8EBC18A4CB3CCE0B07C725F6E0000027732 B40000'>Our shared Public folder</a>
    This link is "made" with the linker program(see link lower down), and when I use it in my web page, anyone can click that link to open our shared folder no matter on which PC they are.

    For information purposes only (not an advertising), i provide a link to the thread where i first noticed the possibility to do this - Creating outlook links

    My question is how to do this with PHP, to be able to construct such an ID that I can incorporate into a link.

    Thanks again
    Best regards


  •  

    Tags for this Thread

    Posting Permissions

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