ESMTP Auth Login Narrowed down: Base64

Sylonious

Freshman
Joined
Apr 12, 2003
Messages
27
I've got my problem narrowed down to the Auth Login (in VB.Net). This is the only problem I am having. I can't figure out how to properly convert the the byte to base64 encoding (VB.Net) to send.

Public Function Open()
client.Connect(_server, _port)
ns = client.GetStream()

Dim strMessage As String = "HELO" & ControlChars.CrLf
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(strMessage)
ns.Write(sendBytes, 0, sendBytes.Length)

Dim StrMessage2 As String = "Auth Login" & ControlChars.CrLf
Dim sendBytes2 As [Byte]() = Encoding.ASCII.GetBytes(StrMessage2)
ns.Write(sendBytes2, 0, sendBytes2.Length)

Dim ConvertBytes3
ns = client.GetStream()
Dim StrMessage3 As String = "User " & _Username & ControlChars.CrLf
Dim sendBytes3 As [Byte]() = (Encoding.ASCII.GetBytes(StrMessage3))
ConvertBytes3 = Convert.ToBase64String(sendBytes3)
ns.Write(ConvertBytes3, 0, ConvertBytes3.Length)


Dim ConvertBytes4
Dim StrMessage4 As String = "Pass " & _Username & ControlChars.CrLf
Dim sendBytes4 As [Byte]() = Encoding.ASCII.GetBytes(StrMessage4)
ConvertBytes4 = Convert.ToBase64String(sendBytes4)
ns.Write(ConvertBytes4, 0, ConvertBytes4.Length)



End Function
 
Last edited:
Visual Basic:
Dim sBase64 As [msdn=System.String]String[/msdn] = [msdn=System.Convert]Convert[/msdn].ToBase64String(sendBytes4)
... should work just fine, assuming that sendBytes4 is not a null value.
 
My client.Getstream.Write does not work with strings. What do I use to write the response back to the server?

This only wokred with Bytes.
ns = client.GetStream()
ns.Write(sBase64, 0, sBase64.Length)
 
Back
Top