Android Tutorial Send email attach file

hi

I was try to use this sample from the forum to send email and attach file
I can send email but not the file


Code:
Dim r As Reflector
Dim f As Object
f = r.CreateObject2("java.io.File", Array As Object("file:///sdcard/spectacle.pdf"), Array As String("java.lang.String"))
Dim share As Intent
share.Initialize(share.ACTION_SEND,"")
share.SetType("*/*")
share.PutExtra("android.intent.extra.STREAM", r.RunStaticMethod("android.net.Uri", "fromFile", _
    Array As Object(f), Array As String("java.io.File")))
share.WrapAsIntentChooser("Share PDF:)")
StartActivity(share)
 
Thanks

can you open new email to add email address from contact book before
you send the email with NET library.

Regards
Sigster
 
For better email handling you should use the NET library.

Hi NJDude,

Code:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        SMTP.Initialize("smtp.gmail.com", 465, "[email protected]", "mypassword", "SMTP")

... how do I get userid and password of users who install the app!? I only know my settings ...

tnx
 
You have a couple of ways, one would be like Erel mentioned on his post above and use the EMAIL object, or, if you prefer, the NET library, but you then will have to create a "config" page and ask the user for his name and password.
 
Hi i have a simulair problem

i will sent a picturte made with the advanced camera

But the fill will not attach to the email (can't find the file)

here is the code

Code:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Camera1 As AdvancedCamera
   Dim Button1 As Button
   Dim Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("Layout1")

End Sub

Sub Activity_Resume
  Camera1.Initialize(Panel1, "Camera1")
End Sub


Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Camera1_Ready (Success As Boolean)
    If Success Then
        Camera1.StartPreview
        Camera1.OriPortrait
Else
        ToastMessageShow("Cannot open camera.", True)
    End If
End Sub
Sub Button1_Click
   Camera1.TakePicture
End Sub
Sub Camera1_PictureTaken (Data() As Byte)
 Dim out As OutputStream
    out = File.OpenOutput(File.DirInternal, "Image.jpg", False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
     'ToastMessageShow("Image saved: " & File.Combine(File.DirInternalCache, "Image.jpg"), True)
    Dim Message As Email
Message.To.Add("[email protected]")
Message.Attachments.Add(File.Combine(File.DirInternal, "Image.jpg"))
StartActivity(Message.GetIntent) 
End Sub
 
Code:
...
out = File.OpenOutput(File.DirInternal, "Image.jpg", False)
...

If I remember right, I had some similar problem some time ago. I think you can't attach a file wich is in 'DirInternal' because, as mail attachement, this file will not behave any more as one for exclusive internal app usage. Try saving 'Image.jpg' under 'DirDefaultExternal' or similar.
 
Last edited:
Back
Top