This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Outlook calendar
#1
Hello,

I searched but didn't find anything in the search engine, so I'm opening a new topic.

I need a script for outlook that can take information from the calendar. The idea is to be able to turn on the ventilation in a hall automatically during the hours in which the hall is engaged via email. It would be nice if information about who saved it and the topic of the meeting could be retrieved. Is it possible to do something like this?
Reply
#2
this could be a good starting point....
https://stackoverflow.com/questions/2426...s-with-lua

we do only need imap4 and pop3 library availble in LM Wink
Reply
#3
It can be added to LM as a user library: https://github.com/jesrui/imap4.lua/blob.../imap4.lua (slightly updated version with some fixes)
Reply
#4
(07.07.2022, 08:45)admin Wrote: It can be added to LM as a user library: https://github.com/jesrui/imap4.lua/blob.../imap4.lua (slightly updated version with some fixes)

Hello,

Unfortunately, I'm a newbie to programming and I'm having a hard time understanding the code. Can you refer me to some additional literature on imap4.lua
Reply
#5
Use attached imap.lua to create a user library called imap.
This example fetches 3 newest emails from inbox. (App password is needed for this to work with Gmail dues to 2-step auth requirements).
For each email the first 8k (8192 bytes) of data is fetched. Fetching the whole email can lead to an out-of-memory condition if it has a large attachment. Each email has a unique id (UID) which should be an always increasing value. You can put the maximum UID of already parsed message into storage to skip emails that have already been parsed. Extracting data from the email depends on the format. Usually it's HTML split into lines with fixed width so parsing it might be tricky, unless there's an ICS file attached.

Code:
user = 'user@gmail.com'
pass = 'PASSWORD'

imap = require('user.imap')
conn = imap('imap.gmail.com', 993, { protocol = 'tlsv1_2' })

caps = conn:login(user, pass)
info = conn:examine('INBOX')

mcnt = 3 -- number of messages to fetch
query = math.max(1, info.exist - mcnt)
msgs = conn:fetch('(UID BODY.PEEK[HEADER.FIELDS (From Date Subject)])', query .. ':*')

for _, msg in pairs(msgs) do
  log('message', msg.id, msg.UID, msg.BODY.value)

  data = conn:fetch('BODY[]<0.8192>', msg.id)
  log(data[1].BODY.value)
end

conn:logout()

Attached Files
.lua   imap.lua (Size: 17.76 KB / Downloads: 12)
Reply
#6
(12.07.2022, 11:01)admin Wrote: Use attached imap.lua to create a user library called imap.
This example fetches 3 newest emails from inbox. (App password is needed for this to work with Gmail dues to 2-step auth requirements).
For each email the first 8k (8192 bytes) of data is fetched. Fetching the whole email can lead to an out-of-memory condition if it has a large attachment. Each email has a unique id (UID) which should be an always increasing value. You can put the maximum UID of already parsed message into storage to skip emails that have already been parsed. Extracting data from the email depends on the format. Usually it's HTML split into lines with fixed width so parsing it might be tricky, unless there's an ICS file attached.

Code:
user = 'user@gmail.com'
pass = 'PASSWORD'

imap = require('user.imap')
conn = imap('imap.gmail.com', 993, { protocol = 'tlsv1_2' })

caps = conn:login(user, pass)
info = conn:examine('INBOX')

mcnt = 3 -- number of messages to fetch
query = math.max(1, info.exist - mcnt)
msgs = conn:fetch('(UID BODY.PEEK[HEADER.FIELDS (From Date Subject)])', query .. ':*')

for _, msg in pairs(msgs) do
  log('message', msg.id, msg.UID, msg.BODY.value)

  data = conn:fetch('BODY[]<0.8192>', msg.id)
  log(data[1].BODY.value)
end

conn:logout()
What I want to do is analyze an ICS file. When someone sends a meeting invitation with an ICS file to a LM email, the script should store in an object the names of the sender, the subject of the email, if the time slot is free to confirm the meeting and run a certain scene say 30 minutes before the meeting. Also if there is already an engagement in that time slot to send the appointment rejection. I don't know where and how to schedule the occupancy of the hall.
Reply
#7
While this is doable this is too complicated and won't be a 100% stable solution.
There's an option to access Outlook calendar via API: https://docs.microsoft.com/en-us/graph/a...-view=true
Example of a similar integration: https://forum.logicmachine.net/showthread.php?tid=3059
Reply
#8
(12.07.2022, 13:54)admin Wrote: While this is doable this is too complicated and won't be a 100% stable solution.
There's an option to access Outlook calendar via API: https://docs.microsoft.com/en-us/graph/a...-view=true
Example of a similar integration: https://forum.logicmachine.net/showthread.php?tid=3059

Thanks for the help, I'll look into it and try it out
Reply


Forum Jump: