Index: trunk/email2trac.py.in
===================================================================
--- trunk/email2trac.py.in	(revision 276)
+++ trunk/email2trac.py.in	(revision 278)
@@ -230,4 +230,9 @@
 			self.REFLOW = 1
 
+		if parameters.has_key('drop_alternative_html_version'):
+			self.DROP_ALTERNATIVE_HTML_VERSION = int(parameters['drop_alternative_html_version'])
+		else:
+			self.DROP_ALTERNATIVE_HTML_VERSION = 0
+
 		if parameters.has_key('strip_signature'):
 			self.STRIP_SIGNATURE = int(parameters['strip_signature'])
@@ -1104,14 +1109,22 @@
 		appledouble_parts = []
 
+		ALTERNATIVE_MULTIPART = False
+
 		for part in msg.walk():
 			if self.DEBUG:
+				print 'TD: Message part: Main-Type: %s' % part.get_content_maintype()
 				print 'TD: Message part: Content-Type: %s' % part.get_content_type()
-				
+
+
 			# Check whether we just finished processing an AppleDouble container
 			if part not in appledouble_parts:
 				appledouble_parts = []
 
-			# Special handling for BinHex attachments. Options are drop (leave out with no warning), warn (and leave out), and keep
+			## Check content type
+			#
 			if part.get_content_type() == 'application/mac-binhex40':
+				#
+				# Special handling for BinHex attachments. Options are drop (leave out with no warning), warn (and leave out), and keep
+				#
 				if self.BINHEX == 'warn':
 					message_parts.append("'''A BinHex attachment named '%s' was ignored (use MIME encoding instead).'''" % part.get_filename())
@@ -1120,31 +1133,51 @@
 					continue
 
-			# Special handling for AppleSingle attachments. Options are drop (leave out with no warning), warn (and leave out), and keep
-			if part.get_content_type() == 'application/applefile' and not part in appledouble_parts:
-				if self.APPLESINGLE == 'warn':
-					message_parts.append("'''An AppleSingle attachment named '%s' was ignored (use MIME encoding instead).'''" % part.get_filename())
-					continue
-				elif self.APPLESINGLE == 'drop':
-					continue
-
-			# Special handling for the Mac-specific part of AppleDouble attachments. Options are strip (leave out with no warning), warn (and leave out), and keep
-			if part.get_content_type() == 'application/applefile':
-				if self.APPLEDOUBLE == 'warn':
-					message_parts.append("'''The resource fork of an attachment named '%s' was removed.'''" % part.get_filename())
-					continue
-				elif self.APPLEDOUBLE == 'strip':
-					continue
-
-			# If we entering an AppleDouble container, set up appledouble_parts so that we know what to do with its subparts
-			if part.get_content_type() == 'multipart/appledouble':
+			elif part.get_content_type() == 'application/applefile':
+				#
+				# Special handling for the Mac-specific part of AppleDouble/AppleSingle attachments. Options are strip (leave out with no warning), warn (and leave out), and keep
+				#
+				
+				if part in appledouble_parts: 
+					if self.APPLEDOUBLE == 'warn':
+						message_parts.append("'''The resource fork of an attachment named '%s' was removed.'''" % part.get_filename())
+						continue
+					elif self.APPLEDOUBLE == 'strip':
+						continue
+				else:
+					if self.APPLESINGLE == 'warn':
+						message_parts.append("'''An AppleSingle attachment named '%s' was ignored (use MIME encoding instead).'''" % part.get_filename())
+						continue
+					elif self.APPLESINGLE == 'drop':
+						continue
+
+			elif part.get_content_type() == 'multipart/appledouble':
+				#
+				# If we entering an AppleDouble container, set up appledouble_parts so that we know what to do with its subparts
+				#
 				appledouble_parts = part.get_payload()
 				continue
 
-			# Any other multipart/* is just a container for multipart messages
+			elif part.get_content_type() == 'multipart/alternative':
+				ALTERNATIVE_MULTIPART = True
+				continue
+
+			# Skip multipart containers
+			#
 			if part.get_content_maintype() == 'multipart':
+				if self.DEBUG:
+					print "TD: Skipping multipart container"
 				continue
-
+			
 			# Check if this is an inline part. It's inline if there is co Cont-Disp header, or if there is one and it says "inline"
 			inline = self.inline_part(part)
+
+			# Drop HTML message
+			if ALTERNATIVE_MULTIPART and self.DROP_ALTERNATIVE_HTML_VERSION:
+				if part.get_content_type() == 'text/html':
+					if self.DEBUG:
+						print "TD: Skipping alternative HTML message" 
+
+			        	ALTERNATIVE_MULTIPART = False
+					continue
 
 			# Inline text parts are where the body is
