| Author |  | 
      
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Howdy,
           | Posted: 16 October 2007 at 1:47pm | IP Logged |   |  
           | 
 |  picking up and resuming my project here.  I've been trying to get the Unique-ID from an email message as I need to save each individual email into one folder.  I may have hundreds or thousand+ emails in the folder, so a definitive unique name is a must.
 
 Here is what I have using messageID - but I understand that is not as reliable as Unique-ID.  Yet I cannot find anything in the docs that show it (I have found stuff that says this is where but that's all).
 
 Here is what I have for code on message-ID  If I try GetMessageUID - it throws an error on the GetMessageUID name. (invalid property assignment)
 
 If objPOP3.MessageCount > 0 Then
 Set objMSG = objPOP3.RetrieveMessages
 If Not objMSG Is Nothing Then
 for each objMSG in objMSG
 mailcount=mailcount+1
 strMailItem=objMSG.MessageID
 strMailItem=replace(strMailItem,"<","")
 
 strMailItem=replace(lcase(strMailItem),"@ephweb.com>","")
 response.write objMSG.Subject & " - " & strMailItem & "!!<BR>"
 For Each objAttach In objMsg.Attachments
 response.write objAttach.Filename & "!!<BR>"
 If Not objAttach.SaveFile ("D:\path_to\leadmanager\htdocs\cust_email_attach\") Then Response.write "I/O Error"
 ' In ASP, use Response.Write instead of MsgBox
 Next
 objMSG.SaveMessage "D:\path_to\leadmanager\htdocs\cust_emails\" & strMailItem & ".eml"
 response.write "<BR><BR>"
 NEXT
 End If
 End If
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Andrew AfterLogic Support
 
  
 
 Joined: 28 April 2006
 Location: United States
 Online Status: Offline
 Posts: 1189
 | 
          Perhaps, you tried to call Message.GetMessageUID method, but Message object doesn't have such method. However, POP3 object does have GetMessageUID method.
           | Posted: 17 October 2007 at 4:01am | IP Logged |   |  
           | 
 |  
 There is no "Unique-ID" header in messages. UID is a POP3 server feature which assigns unique identifier to each message in the mailbox (and this ID is unique for that mailbox only).
 
 Try to implement something like the following:
 
 
 
| Code: 
 
    
    | 
      
       | strMailItem=objPOP3.GetMessageUID(mailcount) |  |  |  
 instead of:
 
 
 
| Code: 
 
    
    | 
      
       | strMailItem=objMSG.MessageID |  |  |  
 Alternatively, you may implement unique names generator based on current date/time value plus a counter. Or use FileSystemObject.GetTempName method to get unique filenames.
 
 Best regards,
 Andrew
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          hmmm
           | Posted: 18 October 2007 at 10:20am | IP Logged |   |  
           | 
 |  okay, yeah looks like a Unix time stamp plus counter is best way to roll with it.
 
 Thanks Andrew.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Ok, I've run into another roadblock.
           | Posted: 18 October 2007 at 1:34pm | IP Logged |   |  
           | 
 |  
 I have successfully - checked the proper email account, saved the entire email to a folder on my server with the .eml extension.  It also saves the attachments just fine.
 
 Now I need to view the saved email.  I looked at the view HTML email tutorial but that seems to only work if your connecting to the mail server again.  How do you load a saved to disk email into the mailbee objects?
 
 I'll then need to be able to either reply or forward it.  Anything special there too?
 
 Thank you.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Andrew AfterLogic Support
 
  
 
 Joined: 28 April 2006
 Location: United States
 Online Status: Offline
 Posts: 1189
 | 
          Message.ImportFromFile method allows loading message from a file.
           | Posted: 19 October 2007 at 12:38am | IP Logged |   |  
           | 
 |  
 "Forwarding message" and "Redirecting message" samples show how to forward or redirect messages. Replying is similar. You may also download and examine MailBee WebMail Lite ASP powered by MailBee Objects.
 
 
 Best regards,
 Andrew
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          okay,
           | Posted: 07 November 2007 at 11:52am | IP Logged |   |  
           | 
 |  
 I still do not see how to put the pieces together.  the webmail lite appears to prefer to use online storage through pop3 vs local storage on the server on the harddrive.
 
 it appears that the message.importfromfile works - at least no error message.
 
 But how do you then use that importfromfile and turn around and show it, and then subsequently use it to reply and / or forward with?
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          The message received from POP3 server and the same message loaded using ImportFromFile as the same. So, you should find the place in the code where the message is being received from the server, insert your code there and use the subsequent code as is. For that code, it's not important how the message object was created. It will reply/forward/whatever the same message object and it's not important you received this object by other means.
           | Posted: 07 November 2007 at 12:01pm | IP Logged |   |  
           | 
 |  
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Hi Alex,
           | Posted: 07 November 2007 at 1:23pm | IP Logged |   |  
           | 
 |  
 The code samples & documentations show it is different.
 
 If objPOP3.Connect Then
 
 ' Download first message completely
 Set objMsg = objPOP3.RetrieveSingleMessage(1)
 
 
 vs
 
 
 If Mailer.Connect Then
 Mailer.Message.ImportFromFile "C:\docs\letter.eml"
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Sorry, I didn't understand. What's different?
           | Posted: 07 November 2007 at 2:59pm | IP Logged |   |  
           | 
 |  
 I mean if you load something into Message from mail server or from file, the contents will be the same (if it's the same message).
 
 And you can then process this message regardless of from which source it was taken.
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          Alex
           | Posted: 08 November 2007 at 3:29pm | IP Logged |   |  
           | 
 |  
 How is it not different?  the code is different.  How can you call the same if it does not load with the same parameters.
 
 If objPOP3.Connect Then
 
 ' Download first message completely
 Set objMsg = objPOP3.RetrieveSingleMessage(1)
 
 
 vs
 
 
 If Mailer.Connect Then
 Mailer.Message.ImportFromFile "C:\docs\letter.eml"
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          I can take and write out objMSG if I retrieved it like that right?
           | Posted: 08 November 2007 at 3:40pm | IP Logged |   |  
           | 
 |  
 but if i were to response.write mailer.message.BodyText - I would get nothing.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | schase02 Newbie
 
  
  
 Joined: 15 October 2004
 Location: United States
 Online Status: Offline
 Posts: 18
 | 
          AHHHA
           | Posted: 08 November 2007 at 3:58pm | IP Logged |   |  
           | 
 |  
 I see it - I was calling for Server.CreateObject("MailBee.POP3")not SMTP
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | juris Groupie
 
  
 
 Joined: 27 June 2011
 Location: Italy
 Online Status: Offline
 Posts: 72
 | 
          
           | Posted: 27 June 2011 at 10:25am | IP Logged |   |  
           | 
 |  
| Andrew wrote: 
 
    
    | 
      
       | ... There is no "Unique-ID" header in messages. UID is a POP3 server feature which assigns unique identifier to each message in the mailbox (and this ID is unique for that mailbox only).
 
 Try to implement something like the following:
 
 
 
| Code: 
 
    
    | 
      
       | strMailItem=objPOP3.GetMessageUID(mailcount) |  |  |  
 Alternatively, you may implement unique names generator based on current date/time value plus a counter. Or use FileSystemObject.GetTempName method to get unique filenames.
 
 Best regards,
 Andrew
 |  |  |  
 Hi Andrew,
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | juris Groupie
 
  
 
 Joined: 27 June 2011
 Location: Italy
 Online Status: Offline
 Posts: 72
 | 
          
           | Posted: 27 June 2011 at 10:31am | IP Logged |   |  
           | 
 |  
| Andrew wrote: 
 
    
    | 
      
       | Alternatively, you may implement unique names generator based on current date/time value plus a counter. Or use FileSystemObject.GetTempName method to get unique filenames. |  |  |  
 Hi Andrew,
 
 I use this code:
 
 
 
| Code: 
 
    
    | 
      
       | string uniqueFileName = msg.MessageID.ToString();
 string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
 Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
 uniqueFileName = r.Replace(uniqueFileName, "");
 uniqueFileName += ".eml";
 
 |  |  |  What do you think?
 
 Regards, Lello
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | juris Groupie
 
  
 
 Joined: 27 June 2011
 Location: Italy
 Online Status: Offline
 Posts: 72
 | 
          To create a unique filename now I use this code
           | Posted: 06 February 2017 at 2:05pm | IP Logged |   |  
           | 
 |  
 
 
| Code: 
 
    
    | 
      
       | private Regex RegularFileNameExpression = new Regex(string.Format("[{0}]", Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()))));
 
 string MyFilename = RegularFileNameExpression.Replace(msg.Date.ToString("yyyyMMddHHmmssfff") + "_" + msg.MessageID + ".eml", "");
 
 
 |  |  |  
 Can anyone tell me if it's okay?
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Maybe it's ok but it's quite complicated. Back in 2000s, we used GetTempName when we needed a unique filename in VBS.
           | Posted: 07 February 2017 at 12:20am | IP Logged |   |  
           | 
 |  
 https://msdn.microsoft.com/en-us/library/w0azsy9b(v=vs.84).aspx
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  |