|
-
Jan 4th, 2009, 04:45 AM
#1
Thread Starter
New Member
[2008] SMTP MailMessage Freezes My PC
Hi,
I'm using the below code to send mail with attachment, its working fine except that my PC freezes for 10 seconds whenever I run this code, is there a way to avoid system lag?,
I tried to lower the process priority by using "Process.GetCurrentProcess.PriorityClass = ProcessPriorityClass.Idle" but it didn't help.
Any suggestions please?
Code:
Dim MyMailMessage As New MailMessage
Try
MyMailMessage.From = New MailAddress("[email protected]")
MyMailMessage.To.Add("[email protected]")
MyMailMessage.Subject = "Mail Subject...."
Dim attch As New Mail.Attachment("C:\Picture.jpeg")
MyMailMessage.Attachments.Add(attch)
MyMailMessage.Body = "Message text...."
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("[email protected]", "myemailpassword")
SMTP.Send(MyMailMessage)
Catch ex As Exception
End Try
-
Jan 4th, 2009, 05:34 AM
#2
Re: [2008] SMTP MailMessage Freezes My PC
Hmmmnnn... Probably using a Backgroundworker to do the sending?
-
Jan 4th, 2009, 07:14 AM
#3
Re: [2008] SMTP MailMessage Freezes My PC
Are you saying that your whole system becomes unresponsive for 10 seconds or just your application? What happens if you send the same e-mail from your default e-mail client?
-
Jan 4th, 2009, 08:07 AM
#4
Thread Starter
New Member
Re: [2008] SMTP MailMessage Freezes My PC
My whole system freezes when using the above code, I tried sending the same email via outlook and it went through without problems!
-
Jan 4th, 2009, 08:20 AM
#5
Re: [2008] SMTP MailMessage Freezes My PC
Is Outlook set up to use port 587 for SMTP as well?
Maybe it is set to use port number 25 which is the default.
Set the port to 25 in your code and see if it works.
-
Jan 4th, 2009, 08:22 AM
#6
Re: [2008] SMTP MailMessage Freezes My PC
Hey,
How big is the attachment that you are trying to add to the email?
You might want to look into the SmtpClients SendAsync method.
http://msdn.microsoft.com/en-us/library/x5x13z6h.aspx
You might have some luck with this.
Hope this helps.
Gary
-
Jan 4th, 2009, 02:18 PM
#7
New Member
Re: [2008] SMTP MailMessage Freezes My PC
Use SMTPClient.SendAsync for a non-blocking operation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|