|
| Decode Base64 Encoded Emails |
| Débuté par guest, 30 aoû. 2016 17:43 - 6 réponses |
| |
| | | |
|
| |
| Posté le 30 août 2016 - 17:43 |
Hi,
I'm trying to read in some emails into my database and some messages are coming in encoded as Base64. I know why this is happening but I'm wondering if anyone knows how to decode the message body in Windev?
Thanks
steve |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 18:41 |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 18:46 |
Quote Paulo Oliveira
did you try with the Uncrypt function?
http://doc.windev.com/en-US/…
You know, I didn't even think about that as I assumed that required some sort of password. (I use encryption in several places in my app) but it appears that you are right.
Decrypting a stream in base64binary format To decrypt a string encrypted in base64, you must use: ResultString = Uncrypt(EncryptedString, "", cryptNone)
Thanks! |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 18:58 |
Hi Steve,
Have you tried to simply use the email variable?
e is email e.Source = [base 64 email]
Best regards, Alexandre Leclerc |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 19:49 |
Quote Alexandre Leclerc
Hi Steve,
Have you tried to simply use the email variable?
e is email
e.Source = [base 64 email]
Best regards,
Alexandre Leclerc
Hi Alexander,
I'm not following. I'm not trying to encode the email message. I'm trying to decode it it into a readable string.
Email..source is encrypted when I read it.
What am I missing?
steve |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 20:03 |
Hi steve,
what Alexandre means is that if you put the whole email into email..source, then you have access to all the email members, including the array of attachments (and the whole base 64 business is all about attachments)
Best regards |
| |
| |
| | | |
|
| | |
| |
| Posté le 30 août 2016 - 20:55 |
Unfortunately, the issue was caused by complex signatures in user emails so the body of message (as far as I can tell) is getting encoded. I ended up writing a procedure to decrypt the message. Here it in case it is helpful to anyone.
PROCEDURE GP_DecryptBase64(sEmailstring is string)
sEncryptedPart is string sDecryptedPart is string sHeader is string sRebuiltMessage is string
nBase64Start is int=Position(sEmailstring,"base64",0,FromBeginning)
IF nBase64Start=0 THEN
RESULT sEmailstring
ELSE
sHeader=Left(sEmailstring,nBase64Start) nBase64End is int=Length(sEmailstring) sEncryptedPart=Middle(sEmailstring,nBase64Start+6,nBase64End-nBase64Start+6)
sDecryptedPart=Uncrypt(sEncryptedPart,"",cryptNone)
sRebuiltMessage=sHeader+sDecryptedPart
RESULT sRebuiltMessage
END |
| |
| |
| | | |
|
| | | | |
| | |
|