Sending emails - add body as file

fatman

Active Member
Licensed User
Longtime User
Hi Folks,

after playing around and heavy searching i cannot solve this problem without help.
Having no problems creating emails that way:

Dim Message As Email
Message.To.Add("[email protected]")
Message.subject = "Test"
Message.Attachments.Add(File.Combine(File.DirRootExternal, "sdcard- disk0/data/transfer/mytext.txt"))
Message.Body = "This is the body of the mail"
StartActivity(Message.GetIntent)

I would like to do something like this:

Message.Body = File.Combine(File.DirRootExternal, "sdcard-
disk0/data/transfer/mybody.txt")

But that does not work...

In short: i create the body of the mail dynamically as a txt-file and i would like to add this file (better the content of this file) to the body.

Any ideas are welcome

Thx Fatman
 

desof

Well-Known Member
Licensed User
Longtime User
B4X:
Sub SENDmail 
'Process_Globals:
Dim SMTP1 As SMTP
Dim server As String     : server= "smtp.gmail.com"
Dim port As Int            : port= 465
Dim emailname As String    : emailname="[email protected]"
Dim password As String    : password="xxxxxxxx"
Dim protocol As String    : protocol="SMTP"
'create
SMTP1.Initialize(server, port, emailname, password, protocol)
SMTP1.UseSSL = True
' sub send:
SMTP1.To.Add ("[email protected]") 
SMTP1.Subject = "someSubject"
SMTP1.Body = "someText"
'''SMTP1.AddAttachment(File.DirDefaultExternal, "examle.txt")
SMTP1.Send

Msgbox ("SEND","")

End Sub


Hi I'm proving this in the emulator and on my Motorola ATRIX and never receive the email. It gives no error and reaches the line MsgBox ("Send", "").

What can it be?
 
Upvote 0
Top