• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scripting Bridge Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting Bridge Question


  • Subject: Scripting Bridge Question
  • From: Dave <email@hidden>
  • Date: Mon, 26 Oct 2015 11:20:26 +0000

Hi,

I’m using the Scripting Bridge to Target MS Outlook. I’m trying to figure out how to do the following AppleScript using the Scripting Bridge. Please see Full Script below, I’ve got most of the code, but I can’t seem to figure out the right Objective-C code for these two statements:

		set myObjectID to the id of (object of myWindow)
		set myContent to the plain text content of message id myObjectID

on run
	tell application id "com.microsoft.Outlook"
		activate
		set myWindow to the front window
		if class of myWindow is not draft window then
			return "Error - Not Draft Window"
		end if

		set myObjectID to the id of (object of myWindow)
		set myContent to the plain text content of message id myObjectID

		return myContent
	end tell
end run


I have the following Objective-C code:

-(BOOL)	outlookGetDraftWindowForWindowIndex:(NSInteger) theWindowIndex returnDraftWindow:(SXOutlook2011DraftWindow**) theDraftWindowPtr  returnMessage:(SXOutlook2011OutgoingMessage**) theOutgoingMessagePtr
{
SXOutlook2011Application*				myOutlookApp;
SBElementArray*                         myOutgoingMessageArray;
SBElementArray*                         myDraftWindowsArray;
SXOutlook2011DraftWindow*				myDraftWindow;
SXOutlook2011OutgoingMessage*			myOutgoingMessage;
SXOutlook2011Object*					myDraftObject;
NSInteger                               myDraftObjectID;

//**
//**	Get the Outlook Application
//**
myOutlookApp = [self.pSingletonManager.pScriptingBridgeManager getHandlerWithAppInternalID:kBundleIDOutlook];
if (myOutlookApp == nil)
	return NO;

if (theDraftWindowPtr != NULL)
	*theDraftWindowPtr = nil;

if (theOutgoingMessagePtr != NULL)
	*theOutgoingMessagePtr = nil;

myOutgoingMessageArray = [myOutlookApp outgoingMessages];
myDraftWindowsArray = [myOutlookApp draftWindows];
if ([myDraftWindowsArray count] < theWindowIndex)
	return NO;

myDraftWindow = [myDraftWindowsArray objectAtIndex:theWindowIndex];
if ([myDraftWindow exists] == NO)
	return NO;

//**
//**    Save the Window before Getting the Message
//**
[myDraftWindow saveIn:nil as:myDraftWindow.name];

myDraftObject = myDraftWindow.object;
if ([myDraftWindow exists] == NO)
	return NO;

myDraftObjectID = myDraftObject.id;
myOutgoingMessage = [self findMessageWithID:myDraftObjectID inArray:myOutgoingMessageArray];

if (theDraftWindowPtr != NULL)
	*theDraftWindowPtr = myDraftWindow;

if (theOutgoingMessagePtr != NULL)
	*theOutgoingMessagePtr = myOutgoingMessage;

return YES;
}


Which works but takes for ever because:

myOutgoingMessage = [self findMessageWithID:myDraftObjectID inArray:myOutgoingMessageArray];

Does a sequential search of the Outgoing Message array, which is ok if there are only a few messages but as soon as you get more than about 100 it takes way too long.

Any ideas on this would be greatly appreciated.

All the Best
Dave
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: Scripting Bridge Question
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: NSFileManager problem
  • Next by Date: Re: NSFileManager problem
  • Previous by thread: Re: NSFileManager problem
  • Next by thread: Re: Scripting Bridge Question
  • Index(es):
    • Date
    • Thread