I’m trying to send an email to myself to see if I can get this working. When I try this I get a NilObjectException on the lines
socket1.Address= "12.24.24.24.24"
socket1.port = 25 What does that mean, why do I get that?
Thanks!
Here’s full code:
[code] Dim mail As EmailMessage
Dim file as EmailAttachment
Dim i as Integer
Dim s as String
'Socket1 is an SMTPSocket
socket1.Address= “12.24.24.24.24”
socket1.port = 25
socket1.username =“ramster59”
socket1.password = “hello123”
Dim mail as New EmailMessage mail.fromAddress="hi@gmail.com"
mail.subject=“hi”
mail.bodyPlainText = “pls”
mail.bodyHTML = “?”
mail.headers.appendHeader “X-Mailer”,“Example SMTP Demo”
mail.addRecipient(“ram9@gmail.com”)
'file = New EmailAttachment
'file.loadFromFile GetFolderItem(fileFld.text)
'mail.attachments.append file
// send the email
socket1.messages.append mail
socket1.sendMail
MsgBox(“sent??”)
[/code]
[quote=152683:@Rami Hassan]I’m trying to send an email to myself to see if I can get this working. When I try this I get a NilObjectException on the lines
socket1.Address= "12.24.24.24.24"
socket1.port = 25 What does that mean, why do I get that?
Thanks!
Here’s full code:
[code] Dim mail As EmailMessage
Dim file as EmailAttachment
Dim i as Integer
Dim s as String
'Socket1 is an SMTPSocket
socket1.Address= “12.24.24.24.24”
socket1.port = 25
socket1.username =“ramster59”
socket1.password = “hello123”
Dim mail as New EmailMessage mail.fromAddress="hi@gmail.com"
mail.subject=“hi”
mail.bodyPlainText = “pls”
mail.bodyHTML = “?”
mail.headers.appendHeader “X-Mailer”,“Example SMTP Demo”
mail.addRecipient(“ram9@gmail.com”)
'file = New EmailAttachment
'file.loadFromFile GetFolderItem(fileFld.text)
'mail.attachments.append file
// send the email
socket1.messages.append mail
socket1.sendMail
MsgBox(“sent??”)
[/code][/quote]
[quote=153179:@Rami Hassan]I just made a property that I made a ‘SMPTSocket’ called ‘socket1’.
I wasn’t sure what I was meant to do.[/quote]
You may want to put your Socket1 at the minimum as a session property, so it does not go out of scope when you try to send.
Here is what I use in an app on my site where users can send a message in a form :
app.theMailServer is an SMTPSocket property of app.
Dim mail As New EmailMessage
mail.fromAddress= TextField1.Text
mail.subject= "Match-Software.com / Message"
mail.bodyPlainText = TextArea1.text
mail.headers.appendHeader "X-Mailer","SMTP"
mail.addRecipient "mymailaddress@mysite.com"
app.theMailServer.messages.append mail
app.theMailServer.sendMail
msgBox "Your message has been sent. I will be processed as soon as possible. Thank you."
showurl "http://Match-Software.com"
As you can see, it is very close to what you have so far. It has been on my site for over a year.
Thanks, what do I put as the Address, username and password though?
I put my email and a random username as password, is that wrong?
IsConnected was = false so?
[quote=153223:@Rami Hassan]Thanks, what do I put as the Address, username and password though?
I put my email and a random username as password, is that wrong?
IsConnected was = false so?
I appreciate the help so far.[/quote]
Most SMTP servers today require the name of the user, usually in the form of his email address, and a password. I use my own site smtp server, but you may want to create an email address with your Internet provider. In general, you will get the necessary information such as port number and, username and password when you create the address.
Some companies provide free smtp. See https://duckduckgo.com/?q=free+smtp but they may not be as reliable, or mail may get blocked on arrival, as many of them are used by spammers.
[quote=153227:@Michel Bujardet]Most SMTP servers today require the name of the user, usually in the form of his email address, and a password. I use my own site smtp server, but you may want to create an email address with your Internet provider. In general, you will get the necessary information such as port number and, username and password when you create the address.
Some companies provide free smtp. See https://duckduckgo.com/?q=free+smtp but they may not be as reliable, or mail may get blocked on arrival, as many of them are used by spammers.[/quote]
Oh, I was under the impression I could create one simply with Xojo haha.
I’ll take a look at them; thanks for your help!