[futurebasic] Re: [FB] email

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 12 Aug 2012 11:42:52 -0400
Doug asked:

> I need to make a CF string from a variable for everything. Can you tell me how to do this?


I don't quite understand exactly what you want. You can create CFStringRef variables for input into the function in several different ways. Try using the code below in the demo.

If you want a single CFStringRef that includes name, address, subject, and message, the SendMail function would have to be rewritten to parse the fields from the single string. The easiest way would be to create a CFArray from the CFString and parse out each field.

A little clarification would help.


'-------------- Main -----------------

dim as Str255 s
dim as CFStringRef name, address, subject
dim as CFMutableStringRef message

// From Pascal string
s = "John Doe"
name = fn CFStringCreateWithPascalString( 0, #s, _kCFStringEncodingMacRoman )

// Copy literal string
address = fn CFStringCreateCopy( _kCFAllocatorDefault, @"johndoe@..." )

// Create with format
subject = fn CFStringCreateWithFormat( _kCFAllocatorDefault, NULL, @"%@", @"Subject line for test." )

// Create mutable string
message = fn CFStringCreateMutable( _kCFAllocatorDefault, 0 )
CFStringAppend ( message, @"Here is some text for the message.\n\n" )
CFStringAppend ( message, @"The message body can be as long as you like." )

fn SendEmail( name, address, subject, message )

CFRelease( name )
CFRelease( address )
CFRelease( subject )
CFRelease( message )