I am trying to create a meeting invite in outlook 2011 using apple script. I have open the dictionary for outlook meeting class
and I tried to create meeting event using
tell application "Microsoft Outlook"
set currentTime to (the current date)
set newEvent to make new calendar event with properties {location:"Dial In : +4319284090, Conference code: 5270687926", start time:(currentTime + (60 * 60)), end time:(currentTime + (60 * 60) + (60 * 60) / 2), content:fileContents}
set newMeeting to make new meeting message with properties {meeting:newEvent}
open newMeeting
end tell
but i am getting the error
error "Microsoft Outlook got an error: AppleEvent handler failed." number -10000
does any one can help me, I will appreciate your effort.
According to the dictionary, a meeting message is A meeting message recieved by the user. This is not the actual message that goes out as invitations. In other words, a meeting message is the message that shows up in your inbox when someone else invites you to a meeting.
The calendar event has an attendee property. I wasn't able to get it to work in the 10 minutes I spent playing with it, but my assumption is an invitation will go out to attendees when the calendar event is created.
Note that attendee is a read-only list. When you create the event, you have to specify a list of required attendees and optional attendees.
Related
I am new to VBA and also new here.
Background:
I have just migrated some users from an IMAP server to Exchange. Everything went well except for one user that uses Apple mail app in MacOS. I moved within that app but the sent messages got messed up. The mail app sets the current time as the received time. The mail app and the maiapp in iPhone also uses this timestamp for sorting. So, now I have to find a way to change the received time to the sent time.
I found an answer here:
https://vox.veritas.com/t5/Enterprise-Vault/EV-is-it-possible-to-change-the-date-when-an-email-was-journaled/td-p/590495
I modified it slightly. The error I get is that Item.ReceivedTime is write-protected. How do I get around this?
Sub sent-received()
Set rSession = CreateObject("Redemption.RDOSession")
rSession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set Msg = Application.ActiveExplorer.CurrentFolder
For Each Item In Msg.Items
Item.ReceivedTime = Item.SentOn
Item.Save
Next
End Sub
I need to validate if an incoming mailitem is signed in Outlook 2010.
If a mailitem is not signed, it should be moved into a "NOSIG"-folder.
While researching, I found (and sort of confirmed) that Outlook 2010 modifies the MessageClass to "IPM.Note", so I tried to use the PropertyAccessor and read the Security-Flags.
Here's my code so far:
Sub TRCR(MAIL_ITEM As MailItem)
Dim PR_SECURITY_FLAGS As Integer
On Error Resume Next
'Security-Flags: 0=none, 1=encrypted, 2=signed, 3=both
PR_SECURITY_FLAGS = MAIL_ITEM.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x6E010003")
'Modulo because, sometimes the flags value is added to a multiple of 32... <unfortunately I lost the source>
If (PR_SECURITY_FLAGS > 32) Then PR_SECURITY_FLAGS = PR_SECURITY_FLAGS Mod 32
If PR_SECURITY_FLAGS = 2 Or PR_SECURITY_FLAGS = 3 Then
'Do all that fancy stuff I want to with that signed Mail
Else
MAIL_ITEM.Move Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders.Item("NOSIG")
End If
End Sub
I use an Outlook rule to run that script on every incoming E-Mail.
It sometimes moves signed mails to the NOSIG folder.
In those cases, the PR_SECURITY_FLAGS were both at 0, before and after that Modulo-Codeline. So being 0, the script worked right but since the mail was signed, the flag shouldn't have been 0 but 2.
I resent the same signed mail dozens of times, just to always see the same thing happening. Most of them are treated correctly while a few always appeared to show the flag 0 instead of 2 while they were signed.
I tried to pause the script for 1-5 seconds with Application.Wait Now + TimeSerial(0, 0, 1) thinking that the script may be too fast for the PropertyAccessor or something, but the pause didn't work. (I couldn't "feel" that five seconds delay while processing multiple mails.)
I start to think that it is an Outlook problem (maybe manipulating Security-Flags similar to MessageClass but not every time).
PR_SECURITY_FLAGS is only set on the outgoing messages to tell Outlook to encrypt the message when it is actually sent. It will not be present on the incoming messages - take a look at the messages with OutlookSpy (I am its author - click IMessage button).
For the incoming messages, you'd think you could check the MessageClass property and see if it is "IPM.Note.SMIME.MultipartSigned", but OOM tries real hard to represent signed and encrypted messages as the regular IPM.Note messages. You would have to either bypass OOM completely and use Extended MAPI (C++ or Delphi only) or you can use Redemption (any language, including VBA, I am its author). Something like the following would let you check the real message class:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set SourceMsg = Session.GetRDOObjectFromOutlookObject(MAIL_ITEM , true)
MsgBox SourceMsg.MessageClass
I'm fairly new to VBA code and have an issue I can't solve. Currently I have taken a VBA script from the internet as seen below:
Public Sub Whatever(Mail As Outlook.MailItem)
Mail.Subject = Mail.Subject & " " & Mail.CreationTime
Mail.Save
End Sub
I then applied this to my inbox using a rule so that it would take the subject and insert the time and date the email was created behind it. The rule looked like so :
Apply to message
on this computer only
run "Project1.Whatever"
This worked great last week but when I tried to use it today it has stopped. Any suggestions as to why this is or whether there is a better way to achieve the same result.
This worked great last week but when I tried to use it today it has stopped.
Why do you need to create a rule if you run it manually each time?
Instead, you can develop a VBA macro which can handle the Startup or MAPILogonComplete events of the Application class and process all items programmatically. See Getting Started with VBA in Outlook 2010 for more information.
I have two mailbox accounts in Outlook 2010.
Primary: Bob#something.com
Secondary: help#something.com
Every time I receive new mail to help#something.com I get the envelope of new mail.
I want to receive the envelope only for Bob#something.com
I cancelled the option to receive envelopes in Outlook.
I created a rule in Outlook 2010 under the account of Bob#something.com
I have the option to run a script but its empty.
I need to write VBA code that can do it:
If (mail was send to Bob#something.com) Then
show Envelope
End If
I know that I can just add the folder of help#something.com instead of its account but it is not possible in my environment (cloud users).
I searched on the web and didn't find anything like this. For example, I did not find what code line can turn the envelope on in Windows.
If you find displaying a message box is an acceptable alternative then the Run a Script format is described here Outlook's Rules and Alerts: Run a Script
From the rule you pass the new mail as "Item" like this:
Public Sub DisplayMessageBox(Item As Outlook.MailItem)
' You need not do anything with "Item" just use it as a trigger
MsgBox "New mail in Bob#something.com"
' or you can enhance the message using "Item" properties
MsgBox "New mail in Bob#something.com - Subject: " & Item.Subject
End Sub
You may also consider ItemAdd or NewMailEx which are a little more complex.
There is an ItemAdd example here How do I trigger a macro to run after a new mail is received in Outlook?
I get two messages everday. The second message must arrive within 3.5 hours; if not, I have to start figuring out what went wrong with the second process that kept that email from getting sent.
Here's what I'd like to see happen.
Message one arrives
A rule executes and flags the message for follow-up (or anything really) 3.5 hours from that time.
There's a "run script" option in Outlook's Rules Wizard that I would use to trigger the script.
Bonus Points:
3 . When the second email arrives, it clears the follow-up flag from the first message.
Here's what I did:
Sub MyRule(Item As Outlook.MailItem)
MsgBox "Mail one has arrived: " & Item.Subject
Dim newMail As Outlook.MailItem
Set newMail = Outlook.CreateItem(olMailItem)
newMail.To = Item.To
newMail.Subject = "!!!Start looking for issues!!!!"
newMail.Body = "Something might have gone wrong with the process.. You did not receive any closing mail for " + Item.Subject + " received on " + Item.ReceivedTime
newMail.DeferredDeliveryTime = DateAdd("h", 3.5, Now)
newMail.Send
End Sub
This mail sits in your outbox for 3.5 hours and then gets sent.
This works only if you keep outlook running about 3.5 hours after the first mail. Till then when you try to close outlook, it will say that there are items in the outbox which are not sent. You can safely ignore this warning, but make sure that you have Outlook running afterwards.
(some of the code was written and tested in Outlook. but the body and subject part i have typed outside the VB Editor. You might have to resolve minor errors.)
EDIT:: for Bonus points..
Sub MyRuleForMessageTwo(Item As Outlook.MailItem)
Dim myitem As Outlook.MailItem
Set OutboxItems = Application.Session.GetDefaultFolder(olFolderOutbox).Items
Set myitem = OutboxItems.GetFirst
Do While Not (myitem Is Nothing)
If myitem.Subject = "!!!Start looking for issues!!!!" Then
myitem.Delete
Exit Do
End If
Set myitem = OutboxItems.GetNext
Loop
End Sub
You can play around with the matching criteria if you expect more than one message to be sitting in your outbox and you want to delete only one.
First of all, it sounds like you are creating a bizarre Rube Goldberg contraption, but that's going to be your problem, not mine, so have fun!
The way I would do this is to write a simple script that iterates through all messages in the inbox. Set the script to run every five minutes or so.
When it finds the first message of a pair, it records the time that message arrived. If it finds the second message, it checks to make sure that it arrived within 3.5 hours. If it doesn't find the second message, it checks if 3.5 hours have elapsed and warns you if they have.
There is no need to set flags on the first message. This doesn't get you any additional information that your script can't figure out later.