Re: email auto-reply program
Re: email auto-reply program
- Subject: Re: email auto-reply program
- From: David Remahl <email@hidden>
- Date: Wed, 20 Jun 2001 16:03:34 +0200
I will be releasing a shareware app soon, and I don't want to be
swamped with emails about the fees from paypal. How do I make an app
that will check an email, scan through the emails, and reply with an
automated message that contains a License number that was generated
randomly. Basically, how do you get and send emails within a program?
Hehe, you're expecting big money? ;-) Hey, this is shareware we're
talking about ;-)
Well, seriously, here is an snippet from NSMailDelivery.h that resides
inside Message.framework:
@interface NSMailDelivery : NSObject
{
}
+ (BOOL)hasDeliveryClassBeenConfigured;
// Returns YES if delivery accounts have been configured or not.
+ (BOOL)deliverMessage: (NSAttributedString *)messageBody headers:
(NSDictionary *)messageHeaders format: (NSString *)messageFormat
protocol: (NSString *)deliveryProtocol;
//
// messageBody is the actual contents of the message. If
messageFormat is NSASCIIMailFormat,
// any rich text or attachments in messageBody will be lost
//
// messageHeaders contains all of the values that will appear in the
message header,
// for example, "To", "From", "Subject", etc. If the value is an
array, the elements
// in the array will converted to a comma seperated list of
values in the message header
//
// messageFormat can be either NSASCIIMailFormat or NSMIMEMailFormat
//
// deliveryProtocol can be NSSMTPDeliveryProtocol
// or nil to use the platform's default deliveryProtocol (this is
the preferred choice).
//
+ (BOOL)deliverMessage:(NSString *)messageBody subject:(NSString
*)messageSubject to:(NSString *)destinationAddress;
//
// messageBody is the plain text contents of the message
//
// messageSubject is the subject of the message
//
// destinationAddress is the recipient's email address, e.g.
email@hidden
//
@end
I'm sure you can use that to send messages...However, the receiving part
is a bit different...You may have to do that yourself...The POP protocol
isn't very difficult though, so using BSD sockets you could whip up
smtng useful in a very short time...It basically goes like this:
Open a connection to the POP server @ port 110.
send 'LIST' + CR
server replies with a list of messages
send 'RETR' + space + message number
server replies with that message, including headers etc.
Then you can process the received data using the normal NSString,
NSScanner etc.
/ regards, david
BTW, if you dont wanna get involved in bsd sockets here, you could maybe
write the app in realbasic..there are ready-made classes for sending and
receiving mail there...And since its not gonna be distributed, you wont
have to worry that its RB. People wont know you're a script kiddie ;-)
J/K.