Sending email messages

brogrammer

New Member
Licensed User
Longtime User
Hi Erel,

I'm trying to use the following piece of code to send an email message when clicked on an item in a ListView. The item clicked holds an email address as String and, when clicked, copies the email address into the TO field of the email messenger. The problem is that it won't... It won't copy the email address and paste it into the TO field. Here is the code:

Dim Message As Email
Message.To.Add("[email protected]")
Message.Attachments.Add(File.Combine(File.DirRootExternal, "Somefile.txt "))
StartActivity(Message.GetIntent)

Please share if you have a solution for this, or if you think that I'm doing something wrong.

Thank you,

Brogrammer.
 

Mahares

Expert
Licensed User
Longtime User
This should do it:
B4X:
Dim MyLV As ListView  'global
Dim MyEmailAdress As String   'global

Sub MyLV_ItemClick (Position As Int, Value As Object)
   MyEmailAdress=Value
End Sub

Message.To.Add(MyEMailAddress)
 
Upvote 0

brogrammer

New Member
Licensed User
Longtime User
Still no success

Thank you for the help. But it still won't work. Here is my whole Sub:

Sub ListView1_ItemClick (Position As Int, Value As Object)

Dim tr As Tutor : tr = Main.currentTutor
Dim t
t = ListView1.GetItem(Position)

Select t
Case tr.getTutorPhone
Dim p As PhoneCalls
StartActivity(p.Call(tr.getTutorPhone))

Case tr.getTutorEmail
Dim Message As Email
Message.To.Clear()
Message.To.Add(tr.getTutorEmail)
Message.Attachments.Add(File.Combine(File.DirRootExternal, " "))
StartActivity(Message.GetIntent)
End Select

End Sub

The case with the Phone Call service works, it reads the phone number off the ListView and calls it. But the second case doesn't. Any ideas why? Appreciate the help.
 
Upvote 0
Top