Here is the code...
This code executes just fine.. the email however is not actually sent until
the application is closed...
Try
Dim objMail As New System.Net.Mail.MailMessage(EMAIL_FROM, UserName &
"@" & ALLOWED_DOMAIN & ".com")
objMail.Attachments.Add(New
System.Net.Mail.Attachment(DecryptedFileName))
objMail.Bcc.Add(EMAIL_FROM)
objMail.Subject = "Decrypted File: " & ShortName
objMail.IsBodyHtml = True
objMail.Priority = Net.Mail.MailPriority.Normal
Dim objSMTP As New System.Net.Mail.SmtpClient(EMAIL_SERVER)
objSMTP.Send(objMail)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
I'd try removing (for testing purposes) .. the attached file.
maybe your app has a lock on the file or something?
you also .. (as a general rule in vb.net) place
Option Strict On
Option Explicit On
at the top of every class...........as in.. ~every class..............
Why?
This line is deficient:
> Dim objMail As New System.Net.Mail.MailMessage(EMAIL_FROM, UserName &
> "@" & ALLOWED_DOMAIN & ".com")
With stronger typing, it should be:
> Dim objMail As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage(EMAIL_FROM, UserName &
> "@" & ALLOWED_DOMAIN & ".com")
I can't prove it does/affects anything, but perhaps it can.
The "Option" stuff makes the syntax more strongly typed, like c#.
> Here is the code...
>
[quoted text clipped - 15 lines]
> MsgBox(ex.ToString)
> End Try
Michael D. Ober - 23 Jun 2006 14:15 GMT
I just put OPs code into a blank VB 2005 project with Explicit and Strict
On. Code will compile as is.
dim objMail as New System.Net.Mail.Message(...)
is syntactically the same as
dim objMail as System.Net.MailMessage = new System.Net.Mail.Message(...)
================
What happens when your code is run in the debugger and you single step
through it? Does the email go immediately or later?
Mike Ober.
What happens when you single step through your code.
> I'd try removing (for testing purposes) .. the attached file.
>
[quoted text clipped - 45 lines]
> > MsgBox(ex.ToString)
> > End Try