Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining real attachments from signature file in Outlook

Status
Not open for further replies.

vaxman9

Programmer
Feb 26, 2002
79
US
Greetings,
We have an application that allow users to save emails and the attachments. They drop an email on a listbox and I process all attachments, saving each as a file. In this new age of marketing and social networking I am seeing more and more facebook, twitter, linkedin and additional signature barnacles in emails in addition to actual files. I can have an email with one valid attachment and 1 or more signatures images. After the user drops an email on the control, they have to go though and delete all the unwanted images.

I am looking for a way to distinguish between a valid attachment and what is a signature attachment.

I would appreciate any suggestions.

thanks
matt
 
Hi Matt,

I can't see how this is possible.

A signature is just part of the message - just like any other text. Unless you can impose some rule on the senders of the messages, so that all their signatures always follow a consistent format, you have got no way of programmatically extracting it.

Also, you talk about a signature "file". I'm not sure what you mean by that.

Also, you mention Outlook in the title of your question. Are you assuming that all the messages will have been composed in Outlook? Why would that be the case?

If I've completely misunderstood the question, my apologies.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike,

Sorry for the confusion, let me try to clarify.

The users drag an outlook message and drops it on my control. I create an object reference to Outlook and a another reference to the message they dropped via the ActiveExplorer of Outlook. This reference's the email within Outlook. Using the message object, I create a reference to the attachment object and start processsing the attachments.

If someone sends an email to a user with a single attachment and the sender has placed a bunch of links in the signature file or just in the email body - links to facebook, twitter, etc - the images of these links appear as attachments to the email. When I process the attachments, I get not only the attachment the sender sent, but I get an image attachment for the each of links as well.

I was hoping that there is a way to differentiate between a file that is "attached" and images/files that are embedded within the message.

I apologize for using the 'signature' - I realize it is nothing more than text. I am seeing a lot of folks creating signature with these social media links and was not clear with the original post.
matt
 
matt,

the best i was able to come up with was to drag the attachment into my application rather than the message.

you may need....

#DEFINE EMAILATTACHMENT -16200

CASE oDataObject.GETFORMAT(EMAILATTACHMENT)




hth

nigel
 
Nigel,

Thanks for the suggestion - I will play with it. Unfortunately, I my users really like being able to drag the message and I am afraid they will bring out the pitchforks and torches if I try to change their behavior =D.

matt
 
Matt,

Thanks for the explanation. It's much clearer now. The only thing I don't understand is the "images of the links". I don't see how a link can have an image, but then I don't know Outlook well enough.

I'm sorry I can't suggest a solution. Perhaps someone else can up with something.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike,

No apologies needed. You are always quick to respond and I've seen many helpful posts from you.

Again, I am real sorry for the poor explaination initially. In Outlook you can insert an image into the body of the message and or when creating a signature file. You can then add a hyperlink to the image so people can click on the image within the email and off they go. Right now it is Facebook, Twitter and LinkedIn barnacles I see growing the most on emails. ;-)

Unfortunately, these become attachments of the email message. I found some info that I think says there is a difference between an embedded image/file and an attached image/file but I have not been able to expose enough of the Outlook model withn VFP to discern how the two attachments are "catagorized" or "typed" for lack of a better term. I guess I'll kick up .Net and go at it on that side.

Thanks

Matt
 
can you loop through the attachments looking for a particular filetype?


TRY
loX = loOutlook.activeinspector.currentitem
CATCH TO oe
loX = loOutlook.ActiveExplorer && get last Selected email
loX = loX.SELECTION.ITEM(1)
ENDTRY
FOR i=1 TO loX.attachments.COUNT
IF lower(JUSTEXT(loX.attachments.ITEM(i).filename)) = "xls"
lcFile = uniquefn(JUSTEXT(loX.attachments.ITEM(i).filename))
loX.attachments.ITEM(i).saveasfile(lcFile)
EXIT
ENDIF
NEXT


n
 
Hi Nigel

That is how I am processing the attachments. I already ignore ".lnk",".exe", etc. Unfortunately if the sender has put a Facebook link within their email body, I will get an attachment named "imagexxx.jpg" that is the Facbook logo. Since My users want to collect all types of files - images included, this is one that would pass the test ...

Thanks!
matt
 
Hello All,
I wanted to update in case anyone else was interested or ran into this issue.

I found a couple of methods for handling attachments embedded in the body of an email verses attached to the email itself. In both cases, the files are found in the message's attachment object.
The first method I found here:
Poster Gary Lee suggested building a list of the attachments and then searching the HTML text of the message body for the filename. If it's found, the image is most likely embedded. This seemed to work pretty good although I had an occasional miss.

The second method and the one I've decided to use incorporates the Redemption product which can be found here:

Redemption does many things, but for this problem I was able to get the CID of each attachment. When the CID is null, this indicates that the file is attached, not embedded. It is extremely easy to incorporate into the existing code:
Original code:
Code:
*
*	Save the Attachments 
*
loOutLook 	= GETOBJECT("","outlook.application") 
loAExplorer	= loOutLook.ActiveExplorer
loItem 		= loAExplorer.Selection.Item(1)

FOR each loAtt in loitem.Attachments
	*
	*	Loop through all the attachement
	*
	lcAttName	= loAtt.FileName
	lcAttach_Id	= PADL(gencode("uploads"),8,"0")	
	loAtt.SaveAsFile(lcSaveBase +lcAttach_Id+"."+JUSTEXT(lcAttName ) )
	this.Parent.AddToUpLoads(JUSTFNAME(lcAttName ),lcAttach_Id ,.f.)
	this.AddItem(JUSTFNAME(lcAttName ))
	this.list[this.listcount,2] = lcAttach_Id && FILE ID
	this.list[this.listcount,3] = "N"		&& EMAIL				
ENDFOR
With Redemption:
Code:
loOutLook 		= GETOBJECT("","outlook.application") 
loAExplorer		= loOutLook.ActiveExplorer
loItem 			= loAExplorer.Selection.Item(1)

loReDemp			= CreateObject("Redemption.SafeMailItem") 
loReDemp.item	= loItem 
FOR EACH loReDemp_Attachment IN loRedemp.Attachments
	*
	* Get the content-ID for the attachment,
	* if present. Thanks to Dmitry Streblechenko,
	* author of Redemption, for the proptag.            
	*
	*	0x3712001E is the PROPTAG for the CID of the Attachment
	*
	lcAttachmentCID = loReDemp_Attachment.Fields(0x3712001E)  && Retrieve CID via Redemption 
	IF ISNULL(lcAttachmentCID)
		lcAttName	= loReDemp_Attachment.FileName
		lcAttach_Id	= PADL(gencode("uploads"),8,"0")		
		loReDemp_Attachment.SaveAsFile(lcSaveBase +lcAttach_Id+"."+JUSTEXT(lcAttName ) )
		this.Parent.AddToUpLoads(JUSTFNAME(lcAttName ),lcAttach_Id ,.f.)
		this.AddItem(JUSTFNAME(lcAttName ))
		this.list[this.listcount,2] = lcAttach_Id	&& FILE ID
		this.list[this.listcount,3] = "N"		&& EMAIL				
	endif
ENDFOR

Thanks to all for the input and suggestions
matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top