[futurebasic] Re: [FB] email

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2012 : Group Archive : Group : All Groups

From: Douglas Stemen <dstemen@...>
Date: Sun, 12 Aug 2012 12:06:51 -0400
Ken,

Everything string that is within quotes needs to be a variable name. For example. every message line  and header information is a record array variable. I do not know how to substitute a record variable name in place of the @"---". 

Thanks,

Doug



On Aug 12, 2012, at 10:47 AM, Douglas Stemen wrote:

> Ken,
> 
> Thank you.
> 
> Sorry to be so stupid about this, but the demo makes a CF string from literals (e.g.  @"John Doe"). I need to make a CF string from a variable for everything. Can you tell me how to do this?
> 
> Thank you,
> 
> Doug
> 
> 
> On Aug 11, 2012, at 2:35 AM, Ken Shmidheiser wrote:
> 
>> Concerning some ancient code, Doug wrote:
>> 
>>> Any help is appreciated,
>> 
>> Wow Doug, that's some old code! Some of the stuff I posted makes me cringe today.
>> 
>> Try this.
>> 
>> Ken
>> 
>> /*
>> 
>>    Automatically formatted email message in Mail
>> 
>>    This FB 5.7.4 OS X Demo will automatically format and, if desired, send
>>    an e-mail message in OS X Mail. Current demo is set up to bring
>>    Mail to the front and format the email for the user to send. Text inputs
>>    are CFStringRefs and thus unlimited in length. An example is provided
>>    showing how a long message can be created.
>> 
>>    This demo uses a mixture of Carbon and Cocoa Apple APIs current as of this date.
>>    Conversion to full Objective-C is trivial, and in fact I converted this from
>>    an Xcode snippet I had on hand.
>> 
>>    Code for automatic, background and hidden sending are remarked out.
>> 
>>    Ken Shmidheiser
>>    Somerset, KY
>> 
>>    August 11, 2012
>>   (Successor to demo released in June 2004)
>> 
>> */
>> 
>> output file "SendMail"
>> compile as "Objective-C"
>> 
>> BeginCDeclaration
>> void processEMail( CFStringRef emailString );
>> EndC
>> 
>> BeginCFunction
>> void processEMail( CFStringRef emailString ) {
>> NSAppleScript *emailScript = [[NSAppleScript alloc] initWithSource:(NSString *)emailString];
>> [emailScript executeAndReturnError:nil];
>> [emailScript release];
>> }
>> EndC
>> toolbox processEMail( CFStringRef emailString )
>> 
>> local fn SendEmail( name as CFStringRef, address as CfStringRef, subject as CfStringRef, content as CFStringRef )
>> '~'1
>> dim as CFMutableStringRef scriptStr
>> 
>> scriptStr = fn CFStringCreateMutable( _kCFAllocatorDefault, 0 )
>> 
>> CFStringAppend( scriptStr, @"set recipientName to """ )
>> CFStringAppend( scriptStr, name )
>> CFStringAppend( scriptStr, @"""\n" )
>> 
>> CFStringAppend( scriptStr, @"set recipientAddress to """ )
>> CFStringAppend( scriptStr, address )
>> CFStringAppend( scriptStr, @"""\n" )
>> 
>> CFStringAppend( scriptStr, @"set theSubject to """ )
>> CFStringAppend( scriptStr, subject )
>> CFStringAppend( scriptStr, @"""\n" )
>> 
>> CFStringAppend( scriptStr, @"set theContent to """ )
>> CFStringAppend( scriptStr, content )
>> CFStringAppend( scriptStr, @"""\n" )
>> 
>> CFStringAppend( scriptStr, @"tell application ""Mail""\n" )
>> 
>> // To send through Mail hidden in backgound, remark out this line...
>> CFStringAppend( scriptStr, @"activate\n" )
>> 	
>> // ... and set visible:false at end of next line.
>> CFStringAppend( scriptStr, @"set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}\n" )
>> CFStringAppend( scriptStr, @"tell theMessage\n" )
>> CFStringAppend( scriptStr, @"make new to recipient with properties {name:recipientName, address:recipientAddress}\n" )
>> 		
>> // To automatically send, rather than just view the message in Mail, un-remark the next line
>> // CFStringAppend( scriptStr, @"send\n" )
>> 		
>> CFStringAppend( scriptStr, @"end tell\nend tell\n" )
>> 
>> call processEMail( (CFStringRef)scriptStr )
>> CFRelease( scriptStr )
>> end fn
>> 
>> dim as CFMutableStringRef message
>> 
>> message = fn CFStringCreateMutable( _kCFAllocatorDefault, 0 )
>> 
>> CFStringAppend( message, @"Here is some text for the message. This is not limited to 255 characters but can be as long as you like.\n" )
>> CFStringAppend( message, @"So I am including a nice little poem for you:\n\n" )
>> CFStringAppend( message, @"Mary had a little lamb,\n" )
>> CFStringAppend( message, @"whose fleece was white as snow.\n\n" )
>> CFStringAppend( message, @"And everywhere that Mary went,\n" )
>> CFStringAppend( message, @"the lamb was sure to go.\n\n" )
>> CFStringAppend( message, @"It followed her to school one day\n" )
>> CFStringAppend( message, @"which was against the rules.\n\n" )
>> CFStringAppend( message, @"It made the children laugh and play,\n" )
>> CFStringAppend( message, @"to see a lamb at school.\n\n" )
>> CFStringAppend( message, @"And so the teacher turned it out,\n" )
>> CFStringAppend( message, @"but still it lingered near,\n\n" )
>> CFStringAppend( message, @"And waited patiently about,\n" )
>> CFStringAppend( message, @"till Mary did appear.\n\n" )
>> CFStringAppend( message, @"'Why does the lamb love Mary so?'\n" )
>> CFStringAppend( message, @"the eager children cry.\n\n" )
>> CFStringAppend( message, @"'Why, Mary loves the lamb, you know.'\n" )
>> CFStringAppend( message, @"the teacher did reply.\n" )
>> 
>> fn SendEmail( @"John Doe", @"johndoe@...", @"This is a test", (CFStringRef)message )
>> CFRelease( message )
>> 
>> 
>> 
>> 
>> --
>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>> 
> 
> 
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>