This message was deleted.
# cfml-beginners
s
This message was deleted.
b
@Dani Szwarc Is it being deprecated or removed?
I ask because I have a client using CFIMAP to get E-mails from Office365, which is what I assume you're talking about.
b
I am also using MS's Graph API for another process for the same customer to check E-mail accounts, and I prefer the JSON REST API to the CFIMAP tag a lot
How you do it depends on how you need to authenticate
d
Brad, I have the authentication going. It's just the attachment part, the "download file" part the one that is driving me nuts
b
They use OAUTH. If you need a single user to login via SSO, and then access their mailbox, you can do that with their auth token. If you need to be able to check any inbox, then you have to do a client-auth flow and create an application with global permissions
But from your last message, I'll assume it's the former 🙂
I haven't downloaded files via the graph API so I'm not sure. if that was what you need help with, I would have mentioned that in your original message along with the code you currently have in place
d
I have followed these steps and it works. It's only one user, where these emails with attachments are being sent. All permissions have been set.
b
Also, this isn't really a "beginner" question so you'd get more eyes on it in the #cfml-general channel
d
Perfect. Thanks a lot Brad!
b
I assume your question is more about how to use the graph REST API than it is how to do it with CF too
d
Well, if I can get a combo "Get Attachments using Graph API with Coldfusion" it would be huge 😄
b
I would assume you have found and read the docs from Microsoft on how their APi works?
I would hope you did that before posting here 🙂
d
Yes, but they are quite confusing to me for the Get Attachment part
b
That guide you linked to says nothing about attachments other than your comment at the bottom
Can you link to the portion of the MS docs you find confusing?
d
Correct, that guide helped me getting connected and the emails. I am trying to understand now the attachment part
b
And you've read the related docs on MS's site for that part of the graph API?
I'm not quite sure I understand the difference between
Copy code
GET /me/mailFolders/{id}/messages/{id}/attachments/{id}
and
Copy code
GET /me/mailFolders/{id}/messages/{id}/attachments/{id}/$value
but slapping those into Postman seems like a good place to start
d
Correct, as far as I could read, there is no information on how to download the attachment, but how to get info about it
or like you found, the raw content of it
b
there is no information on how to download the attachment
Not sure what you mean-- I've already found the information in the docs on how to download an attachment after just a couple minutes of skimming the docs. Did you look there at all?
d
Brad, not coming here to fight nor to prove anything. I have been looking and reading this for a while since found out about the deprecation. Not sure why are you challenging but thank you anyway
b
I'm just trying to help you help you 🙂
I know the graph API docs are large and confusing sometimes since I've used them myself so perhaps I just got lucky in finding the correct portion of the docs. The main takeaway was just to ensure you had done some due diligence first.
d
I appreciate you checking if I had done that. Yes I did. For me, "download raw content of a file" is not download attachment. Maybe I am ignorant, but if the content is raw, it means is not what I am looking for, maybe I need to find a way to convert raw content. Reason why I came here to find out if anyone else went through the same process. I guess in order to ask I need to demonstrate I deserve it.
b
I would start with the
file
attribute of the
cfhttp
tag to download the file. You may need to use
getasbinary
depending on the file type
a
@Dani Szwarc I've been watching along on this thread, and I... erm... @bdw429s is just trying to help. He is ubiquitously helpful, and perennially patient.
Sometimes it's hard to second guess the level at which to pitch help with ppl one doesn't know. Plus verifying one has read the docs / found the docs / tried what it says in the docs is just a sensible line of questioning. But Brad is def just trying to gauge what you know, what you've done, and trying to help you.
d
Yes Adam, maybe I'm too sensitive and felt challenged about what I truly went through. I appreciate Brad's help and you explaining his intentions. Will keep researching on the matter now.
a
I wish I could offer helpful insight, that said. Soz that I can't 😉
b
Yes, apologies if it came off wrong. We have some people in this Slack team who expect a lot of help but put in very little effort of their own. Since your original question was light on details (code samples you tried, errors you received, docs you read, etc), I wasn't sure what you tried. It is customary to include such details when asking a question if you can.
d
Hey Brad, not a problem. Now I understand your questions. Let me explain: I still wasn't able to get the emails because my customer hasn't set up the permissions in Azure properly. But I know that once it is deprecated, this will fall on my back. So I was researching on how to do every single step without understanding much of the Graph API (I've heard of it for the first time because of this, two months ago) and that's how I found the link on LinkedIn I shared with you. Regarding the documentation found on the MS website, maybe because English is not my first language I do not understand all the terminology, however, I did find that we can get a lot of information about the attachment, not the attachment itself. Believe me, I read as much as I could without being able to test because the lack of proper permissions from my client. In regard to our conversation, I became defensive because I felt evaluated when I was trying to find help. Once again, I appreciate you stepping in.
g
Just "shooting from the hip" : Can you create a trila / free account for Azure and do your coding / testing against that? (To rule out your client's permission issues effecting your efforts) Similarly - can you ask them to fix their settings - or create a "special" account for you - for testing with? "IF" it is a permissions thing - you might have already stumbled across a working solution - but ignored it - because it didn't seem to work for you at the time. Of course - Good Luck!
l
@Dani Szwarc I've been successfully doing this with GraphAPI for a while now. Where are you stumbling?
d
Hello @gavinbaumanis, funny enough I just received all the data I need. Now the fun begins! Hello @leftbower, thank you for getting back to me. While going through the documentation I couldn't find the way to download the attachment (pdf files). Get Attachment is confusing, at least for me, maybe because I lack knowledge of the terminology or because I find it unclear. The documentation states "Read the properties, relationships, or raw contents of an attachment that is attached to a user event, message, or group post." What I am looking for is to be able to download it. Now that I have all the proper credentials and permissions, I will start the real testing and see if I can get it with CFHTTP using FILE and GET /users/{id | userPrincipalName}/messages/{id}/attachments/{id}/$value. Is this the way you do it?
l
Basically, I have a scheduled task the reads all mail from a folder into an array. I then
filter
that array so I'm left with only those with attachments, then for
each
one of those messages I get the list of attachments. And then for
each
attachment I get it as
raw
and then use
fileWrite
to save it to disk as an Excel file.
d
@leftbower Andrew thank you very much! I got it working! I was forgetting to add the header to the "Get Attachment" method! I am getting all the files now! Thank you for your help and thank you @bdw429s pointing me in the right direction!
b
FWIW, I converted my client using cfimap over to an Oauth flow this week and not only does it work great, it's much MUCH faster on Lucee when the inbox has lots of messages.
I ended up using the
Copy code
<https://graph.microsoft.com/v1.0/users/><username>/messages/<message id>/attachments
endpoint which contains the base64 encoded binary of the attachments right there in the REST response.