New topic: 

Sending E-mails - Error 103

<http://forums.realsoftware.com/viewtopic.php?t=46300>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        ojtramp          Post subject: Sending E-mails - Error 
103Posted: Thu Dec 20, 2012 7:31 pm                         
Joined: Sat Oct 01, 2011 5:55 am
Posts: 7                I'm getting the error 103 when trying to send e-mails 
from a web application. In testing it all works fine but once I've uploaded the 
application to my server (hostgator) it throws an error. Theres obviously 
something I'm not understanding between the two locations but cant work out 
what!

The code is able to recognise if the account details provided from the text 
boxes are for a hotmail or gmail account (the only two supported) and changes 
the settings of the socket accordingly.

Thanks for your help...


Dim mail as EmailMessage
Dim SMTPSocket1 as new SMTPSecureSocket

'This allows me to add multiple recipients
dim emails() as string
dim recipnames() as string
emails.Append "[email protected]"
recipnames.Append "???? ?????"

'For demo purposes you can add a test e-mail to the list of recipients to see 
the result
if testemail.Text <> "" then
  emails.Append testemail.Text
  recipnames.Append left(testemail.Text, instr(testemail.Text, "@") - 1)
end if

'Recognise account type and change settings accordingly
if instr(AccountDetails.PersonalEmail.Text, "@gmail") <> 0 or 
instr(AccountDetails.PersonalEmail.Text, "@google") <> 0 then
  SMTPSocket1.Address = "smtp.gmail.com"
  SMTPSocket1.Secure = true
else
  SMTPSocket1.Address = "smtp.live.com"
end if

'Add generic settings
SMTPSocket1.port = 587
SMTPSocket1.ConnectionType = 3

' Load settings from textfields on account page
SMTPSocket1.Username = AccountDetails.PersonalEmail.Text
SMTPSocket1.Password = AccountDetails.PersonalEmailPass.Text


'Add recipients
mail = New EmailMessage
dim k as integer = emails.Ubound
mail.BodyHTML= "Dear " + recipnames(k)
mail.AddRecipient emails(k)
k = k - 1
while k >= 0
  if k = 0 then
  mail.BodyHTML=mail.BodyHTML + ", " + recipnames(k)
  mail.AddRecipient emails(k)
  else
  mail.BodyHTML=mail.BodyHTML + " and " + recipnames(k)
  mail.AddRecipient emails(k)
  end if
  k = k - 1
wend


'Setup e-mail
mail.FromAddress = SMTPSocket1.Username
mail.subject= "EMAIL SUBJECT"
mail.BodyHTML = MessageEdit.PersonalMessage.Text 'Load personalised e-mail from 
text field

mail.headers.appendHeader "X-Mailer","REALbasic SMTP Demo"


SMTPSocket1.Messages.Append mail //send the mail
SMTPSocket1.SendMail //send message

MsgBox "Emails Sent - thank you for your support."

AccountDetails.Close 'Window with account details on it
MessageEdit.Close 'Window with personalised message on it

if SMTPSocket1.LastErrorCode = 0 then
  me.Visible = false 'Hides the send button to prevent multiple e-mails being 
sent
else
  MsgBox "Error " + str(SMTPSocket1.LastErrorCode)
end if
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
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

[email protected]

Reply via email to