Android Question BackgroundMail issue and question

Stephen A Wolfe

Member
Licensed User
I saw an old thread which appears to be something I was looking for. I need an app to just send email to my gmail account (for user feedback). The thread suggested I start a new thread, so here it is.

The link I'm referencing is: https://www.b4x.com/android/forum/threads/background-mail.59264/#post-373428

I downloaded the files, added them to my library, ticked the BackgroundMail checkbox, then placed the example code into my project:
B4X:
        bgmail.GmailUserName = "gmail@gmail.com"
        bgmail.GmailPassword = "password"
        bgmail.FormSubject = "PDF Invoice"
        bgmail.MailTo = txtEmail.Text.Trim
        bgmail.FormBody= "Dear customer, the below attachement contains your invoice in pdf format.Please contact us for more details."
        bgmail.Attachment = (File.Combine(File.DirRootExternal, FileName))
        bgmail.SendingMessage= "Sending PDF Invoice To " & txtEmail.Text.Trim
        bgmail.SendingMessageSuccess = "Sent Successfully"
        bgmail.ProcessVisibility = True
        bgmail.send

I'm getting an undeclared variable 'bgmail' error. I must have did something wrong or am missing something.

My second question is: How much of a security risk is it to store my email password in code? I don't see any threads related to BackgroundMail, so there must be a reason people aren't using it and I'm wondering if this is why.

Thanks in advance.
 

Stephen A Wolfe

Member
Licensed User
Silly me. I forgot the Dim bgmail As BackgroundMail. I guess my security question still applies because I do not know how hard it is to deobfuscate the code.
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
How much of a security risk is it to store my email password in code? I don't see any threads related to BackgroundMail, so there must be a reason people aren't using it and I'm wondering if this is why.

first don't use your private email account,make a new one just for this app.

add your gmail password to String variable in Process_Globals

and select "Release(obfuscated)" >> more info about obfuscation https://www.b4x.com/android/forum/threads/code-obfuscation.13773/#content

the variable will be encrypted and will be harder (but not impossible) to read.
 
Upvote 0

Stephen A Wolfe

Member
Licensed User

Thank you for the suggestion. Would it be even more secure if I design the app to only save the credentials in an encrypted file? I do have plenty of alternate gmail accounts, so that's no problem to use a disposable one also.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…