Created
March 27, 2012 01:16
-
-
Save jasonamyers/2211439 to your computer and use it in GitHub Desktop.
MS CRM: Select Email Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
EA.Body, | |
EA.ActivityID, | |
EA.AttachmentNumber, | |
EA.FileName, | |
CONVERT(varchar(255), EA.ActivityID) + '_' + CONVERT(varchar(255), EA.AttachmentNumber) + '_' + CONVERT(varchar(255), EA.Filename) AS SaveAsFileName | |
FROM | |
FilteredEmail E JOIN | |
ActivityMimeAttachment EA ON E.ActivityID = EA.ActivityID | |
WHERE | |
E.regardingobjecttypecode = 1 or -- Accounts | |
E.regardingobjecttypecode = 2 or -- Contacts | |
E.regardingobjecttypecode = 3 or -- Opportunities | |
E.regardingobjecttypecode = 4 -- Leads |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment