I think that it might cause a problem to delete the file just after
calling SMTPSocket.SendMail(). That function is asynchronous and might
not complete before the FolderItem.Delete is called. The same problem
might be happening with the Window.Close() call. If SMTPSocket1 is a
control on the window, that isn't going to be able to send before the
window closes.
- Ryan Dary
Jim Dossey wrote:
Here's the code. This method takes a window, makes an image of it, and
then
emails that image along with a note. The idea was to give users a way of
emailing a screen dump whenever they have a problem. I have a window
with 4
EditFields, FromEmailAddress, ToEmailAddress, MessageSubject and
MessageBody. I also have the source window SrcWindow from which an
Image is
created and attached to the message. And the email server address and port
number are stored in a module.
Dim Image As Picture
Dim Message As EmailMessage
Dim Attachment As EmailAttachment
Dim TempDir, TempFile As FolderItem
If (FromEmailAddress.Text.Len = 0) Then
MsgBox("From Email address is required")
Return
End If
If (ToEmailAddress.Text.Len = 0) Then
MsgBox("To Email address is required")
Return
End If
Image = NewPicture(SrcWindow.Width, SrcWindow.Height, 8)
If (Image Is Nil) Then
MsgBox("Can't create picture. Out of memory")
Return
End If
If (Image.Graphics Is Nil) Then
MsgBox("Can't create picture. Out of memory")
Return
End If
If (Module1.EmailServerAddress.Len = 0 Or Module1.EmailServerPort <= 0)
Then
MsgBox("Please setup an Email Server in the Options screen before using
this option")
Return
End If
SrcWindow.DrawInto(Image.Graphics, 0, 0)
// Save the image to a file so we can attach it to the email
TempDir = TemporaryFolder()
TempFile = TempDir.Child("ScreenDump.jpg")
TempFile.SaveAsJPEG(Image)
SMTPSocket1.Address = Module1.EmailServerAddress
SMTPSocket1.Port = Module1.EmailServerPort
Message = new EmailMessage
Message.FromAddress = FromEmailAddress.Text // add to options screen
Message.Subject = MessageSubject.Text
Message.BodyPlainText = MessageBody.Text
Message.Headers.AppendHeader("X-Mailer", "My Program")
Message.AddRecipient(ToEmailAddress.Text)
Attachment = new EmailAttachment
Attachment.LoadFromFile(TempFile)
Message.Attachments.Append(Attachment)
SMTPSocket1.Messages.Append(Message)
SMTPSocket1.SendMail
TempFile.Delete()
Self.Close
On 7/19/06, Ryan Dary <[EMAIL PROTECTED]> wrote:
Something else is going here because I just built my app using 2006r3,
ran the program on Windows XP and I got the email in my mail program. I
didn't experience the error.
You might consider looking through the transcript closer to see what is
going on here. If you'd like to send me the transcript of the
transaction OFF THE LIST, then I could see if I notice anything.
Just out of curiosity, are you sure you've filled out all the necessary
properties of the sock and added at least one message to the sock?
Perhaps posting that code (or sending it off list) would help narrow
down the problem.
Jim Dossey wrote:
> Has anyone else tried to use an SMTPsocket in 2006R3 in Windows XP?
>
> I have a project where this worked fine under 2006R1. After converting
to
> 2006R3 it stopped working. I used ethereal to find out what was going
on.
> It seems that RB makes the connection to the server on port 25. The
server
> sends back a "220..." message. Then the RB app sends "QUIT" and the
> connection closes. No events fire in the SMTPsocket. I'm not sure
what
to
> try next.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>