SMTPSecureSocket.SMTPConnectionType Enum Puzzle

Today’s adventure included upgrading my app’s email sending to always use SMTPSecureSocket and API 2.0, but I’ve run into a problem saving and restoring the connection type.

This line raises a “type mismatch” error when I try to run the app in the IDE:

My SMTPSecureSocket.SMTPConnectionType = gMySavedSMConnectionType

The problem is the “gMySavedSMConnectionType”, which is currently defined as an integer, which worked with API 1.but that doesn’t work anymore. I know the answer is SMTPSecureSocket.SMTConnectionTypes.STARTTLS, but I can’t figure out what kind of data type that is so I can save/restore it between runs.

The built-in Language Reference can’t find either 'STARTTLS" and “SMTPSecurSocket.SMTPConnectionTypes”, and neither does autocomplete.

So how do I save an Enum value into a preference file and restore it?

[quote=459778:@John McKernon]
So how do I save an Enum value into a preference file and restore it?[/quote]

Cast (or type) to integer and back

My SMTPSecureSocket.SMTPConnectionType = SMTPSecureSocket.SMTConnectionTypes(gMySavedSMConnectionType)

It sure seems like a lot of typing for something so simple, but hey, IT WORKS, and I learned something new!

Thank you-