Lasso Soft Inc. > Home

[email_attachments]

Linkemail_attachments
AuthorJason Huck
CategoryEmail
Version8.5.x
LicensePublic Domain
Posted02 Aug 2007
Updated02 Aug 2007
More by this author...

Description

Returns an array of email attachment data for the given message. Follows the example from the Language Guide with the addition of also including message parts with a content-disposition of "inline." Each item in the array is a map containing the raw message data, the filename, the file's MIME type, and the size.

Sample Usage

var('attachments') = email_attachments($mymsg);

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'attachments',
	-namespace='email_',
	-req='in', -copy,
	-priority='replace',
	-description='Returns an array of email attachment data for the given message.'
);
	protect;
		#in = email_parse(#in);
	/protect;
	
	local('out') = array;

	iterate(#in, local('i'));
		if(#i->content_disposition >> 'attachment' || #i->content_disposition >> 'inline');
			local('item') = map;
			#item->insert('data' = #i->body);
			#item->insert('name' = #i->content_type('name'));
			#item->insert('type' = #i->content_type->split(';')->first);
			#item->insert('size' = #i->body->size);
			#out->insert(#item);
		/if;
	/iterate;

	return(#out);
/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft