Login  
Search All Forums
Dart Home | PowerTCP Mail for ActiveX | Custom Development Reply | PowerTCP Mail for ActiveX Topics | Forums   
AuthorForum: PowerTCP Mail for ActiveX
Topic: See attachments while previewing
User30

Posts: 6
Member Since: 04/23/02
posted April 23, 2002 7:52 AM

Is it possible to find out if a message has any attachments while previewing a list of messages? I get the list of messages with the following code: oMailbox.Get imapGetPreview, "1:4". Obviously I want a way to inform the user that the e-mail has attachments without actually fetching the e-mails.

/pierre
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted April 23, 2002 9:21 AM


Hi pierre,
In addition to headers, preview also includes information about the body of the message. The Message object uses this info to create a Parts collection. You can use the headers in these parts to determine if a message has attachments. A simple example is below.
-ken

box.Get imapGetPreview

Dim m As New Message
Dim p As New Part
For Each m In box.Messages
  For Each p In m.Parts
    Debug.Print p.Header.All
    Debug.Print "----------"
  Next
Next

K M Drake
Dart Tech Support
User72

Posts: 11
Member Since: 04/16/02
posted April 23, 2002 11:56 AM

I made a recursive VB function that will work it for you. All you need is doing a msgGetPreview in the folder then pass a message's .parts property to this function...

-------------------------------------------
function hasAttach(parts)
 has = false
 For Each p In Parts
  s = p.Header.Find(hdrMsgContentType)
  pos = inStrRev(s,"; name=")
  if pos>0 then
   s = trim(mid(s,pos+7))
  else
   s = ""
  end if
  has = has or (s <> "")
  if p.parts.count > 0 then has=has or hasAttach(p.parts)
 Next
 hasAttach = has
end function
--------------------------------------------

now simply call it this way

If hasAttach(myMessage.parts) then
 whatever....

Hope this helps... its a little better than Dart's official response... since this is a recursive function that will look in sub-part trees also...
Reply | PowerTCP Mail for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX