On my Windows 8.1 machine I am able to send text emails to my hotmail.com account. An additional five lines of code (see code) for the email attachment cause the SMTPSocket to time out when trying to send an attachment (jpg less than 150 kb). When I run this on my Mavericks Yosemite machine I am able to send a simple and small text file.
'Assemble the email details
Dim Mail as new EmailMessage
Mail.FromAddress = TFSMTPUser.Text 'Email ‘from’ address
Mail.Subject = TFSMTPSubject.Text 'Subject line of email
Mail.BodyPlainText = TFSMTPMessage.Text 'The email message
Mail.Headers.AppendHeader(“X-Mailer”,“Example”) 'Not manditory for hotmail
Dim file as new EmailAttachment 'these five lines don’t seem to work
'file.ContentEncoding=“Base64”
'file.MIMEType=“image/jpeg”
file.LoadFromFile(f)
Mail.Attachments.Append(file)
'Add details to the email
SMTPSocket1.Messages.Append(Mail)
'Send the complete email
SMTPSocket1.SendMail[/code]
When I run the example program in xojo (Email Example.xojo_binary_project), I get an error that mentions:
Any helpful thoughts? Possibly modify the Email example supplied by Xojo?
[quote=152444:@Eugene Dakin]On my Windows 8.1 machine I am able to send text emails to my hotmail.com account. An additional five lines of code (see code) for the email attachment cause the SMTPSocket to time out when trying to send an attachment (jpg less than 150 kb). When I run this on my Mavericks Yosemite machine I am able to send a simple and small text file.
[/quote]
A shot in the dark as I am ignorant in this area … but try:
'Create the connection
SMTPSocket1.Secure = True
SMTPSocket1.ConnectionType = SSLSocket.TLSv12
'etc
The Send No Attachment pushbutton code successfully sends a text email when a valid SMTP user (eg. me@hotmail.com) with a SMTP password (eg. 12345) is added.
To try and send an email with an attachment, add a valid SMTP user and SMTP password, and press the Add Attachment pushbutton and add a small file such as a jpg. Press the Send With Attachment button and the email hangs.
An attachment doesn’t make any difference at all. The content of a mail is just text. Except if sending mails with attachments is blocked at the recipient or attachments are fished out by enterprise IT.
starttls is initiated with a non-secure connection and won’t work with a secure one.
I don’t have a Hotmail account. Is there a difference to Office 365 Exchange? Got one of these for testing.
Something else to consider. How big is the file you are trying to attach? File attachments are Base64Encoded, so the sending size goes up a bit. Could it be that the attachment is going over the Hotmailattachment limit?
'Assemble the email details
Dim Mail as new EmailMessage
Mail.FromAddress = TFSMTPUser.Text 'Email ‘from’ address
Mail.Subject = TFSMTPSubject.Text 'Subject line of email
Mail.BodyPlainText = TFSMTPMessage.Text 'The email message
Mail.Headers.AppendHeader(“X-Mailer”,“Example”) 'Not manditory for hotmail
'Added three lines for file attachment
Dim file as new EmailAttachment
file.LoadFromFile(f)
Mail.Attachments.Append(file)
'Add details to the email
SMTPSocket1.Messages.Append(Mail)
'Send the complete email
SMTPSocket1.SendMail[/code]
If the three lines for file attachment are deleted or commented out, then the program sends text properly on both port 25 and port 587.
The SMTPConnectionMode must be STARTTLS (SSL/TLS will not send a text message or attachment). Funny thing is the Windows Settings link shows that for a POP3 and SMTP account both SSL and TLS should work.
When I subclassed SMTPSecureSocket, attachments would not go through on Windows. When I created a SMTPSecureSocket object, the attachment goes through on Windows 8.1.
So your socket was going out of scope? That would explain why small emails went through but large ones did not. The small ones had enough time to finish, but not the large ones.
I am not sure what you mean by going out of scope (but I am willing to learn ). My guess is that there may be something in the SecureServerSocket that might have been missed underneath the hood.
Both SSL/TLS and STARTTLS SMTPConnectionModes work on the object, while the subclass only allows STARTTLS to work.