Click here to Skip to main content
15,890,947 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Object reference not set to an instance of an object. Pin
Saqib Jabbar15-Jan-10 18:09
Saqib Jabbar15-Jan-10 18:09 
AnswerRe: Object reference not set to an instance of an object. Pin
Estys15-Jan-10 23:02
Estys15-Jan-10 23:02 
GeneralRe: Object reference not set to an instance of an object. Pin
DaveAuld16-Jan-10 0:32
professionalDaveAuld16-Jan-10 0:32 
GeneralRe: Object reference not set to an instance of an object. Pin
Saqib Jabbar17-Jan-10 18:07
Saqib Jabbar17-Jan-10 18:07 
AnswerRe: Object reference not set to an instance of an object. Pin
JoeSharp15-Jan-10 1:54
JoeSharp15-Jan-10 1:54 
QuestionData Grid Pin
Ganesh Joshi15-Jan-10 0:46
Ganesh Joshi15-Jan-10 0:46 
AnswerRe: Data Grid Pin
DaveAuld15-Jan-10 1:22
professionalDaveAuld15-Jan-10 1:22 
QuestionIssue when creat send email.... [modified] Pin
Golden Jing14-Jan-10 20:57
Golden Jing14-Jan-10 20:57 
Dear All,

I greated small application in VisualStudio2005 to send email with attach file to all my company's customer which take their email from database. So the sending mail process is in loop.
I tested lot time . i change their mail to my mail and friends for test. When i click button "Send Mail" it process is complete but i and friend didn't get any mail.
Note: our company has to usedd mail server as well. I created a Function like bellow:
and Function bellow i imports name space or reference ready.

What is issue of this prople?
Please give me idea or solution. thanks
Under is my function which created.

Function SendEmail(ByVal mBody As String, ByVal mSubject As String, ByVal mFrom As String, ByVal mTo As String, Optional ByVal mCC As String = "", Optional ByVal mBCC As String = "", Optional ByVal pDisplayName As String = "", Optional ByVal pIsBodyHtml As Boolean = False, Optional ByVal pPriority As MailPriority = MailPriority.Normal, Optional ByVal AttPath As String = "") As Integer
        Dim Mail As New System.Net.Mail.MailMessage
        Dim counter As Integer = 0
        Dim MailAddList() As String
        Dim MailList As String
        
        Dim Smtp As New SmtpClient
        Try
            With Mail
                .From = New System.Net.Mail.MailAddress(mFrom.Trim, pDisplayName)
                '---- Insert Recepient mail(To) ----
                MailAddList = Split(mTo, ";")
                For Each MailList In MailAddList
                    .To.Add(MailList)
                Next
                .Priority = pPriority
                .IsBodyHtml = pIsBodyHtml
                '---- Insert CC ----
                If mCC <> "" Then
                    MailAddList = Split(mCC, ";")
                    For Each MailList In MailAddList
                        '.To.Add(MailList)
                        .CC.Add(MailList)
                    Next
                End If
                '---- Insert Bcc ----
                If mBCC <> "" Then
                    '.Bcc.Add(mBCC.Trim)
                    MailAddList = Split(mBCC, ";")
                    For Each MailList In MailAddList
                        .Bcc.Add(MailList)
                    Next
                End If
                .Subject = CStr(mSubject).Trim
                .Body = mBody.Trim
                .DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                'Atach File
                AttFileName = New Attachment(AttPath)
                Mail.Attachments.Add(AttFileName)

            End With
            Smtp.Host = CStr("company.test.com.kh")  'It's replace the IP
            Smtp.Port = 25
            Dim myCredential As New System.Net.NetworkCredential("UserName", "Password")
            Smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
            Smtp.Credentials = myCredential

            Smtp.Send(Mail)
            '----- Delay process 10seconds ------'
            System.Threading.Thread.Sleep(10000)
            '-----------------------------------'
            Return 0
        Catch ex As Exception
            ErrorMessage = ex.Message
            Return -1
        Finally
            If Mail IsNot Nothing Then Mail.Dispose()
            Mail = Nothing
            Smtp = Nothing
        End Try

    End Function


VB.Net

modified on Sunday, January 17, 2010 10:09 PM

AnswerRe: Issue when creat send email.... Pin
DaveAuld15-Jan-10 1:10
professionalDaveAuld15-Jan-10 1:10 
GeneralRe: Issue when creat send email.... Pin
Golden Jing17-Jan-10 16:08
Golden Jing17-Jan-10 16:08 
AnswerRe: Issue when creat send email.... Pin
DaveAuld15-Jan-10 1:20
professionalDaveAuld15-Jan-10 1:20 
GeneralRe: Issue when creat send email.... Pin
Golden Jing15-Jan-10 2:47
Golden Jing15-Jan-10 2:47 
GeneralRe: Issue when creat send email.... Pin
DaveAuld15-Jan-10 4:53
professionalDaveAuld15-Jan-10 4:53 
GeneralRe: Issue when creat send email.... Pin
Golden Jing15-Jan-10 21:14
Golden Jing15-Jan-10 21:14 
GeneralRe: Issue when creat send email.... Pin
DaveAuld16-Jan-10 0:15
professionalDaveAuld16-Jan-10 0:15 
GeneralRe: Issue when creat send email.... Pin
Golden Jing17-Jan-10 15:57
Golden Jing17-Jan-10 15:57 
QuestionMerge two pdf files into one Pin
C#Coudou14-Jan-10 20:52
C#Coudou14-Jan-10 20:52 
AnswerRe: Merge two pdf files into one Pin
dan!sh 14-Jan-10 20:56
professional dan!sh 14-Jan-10 20:56 
AnswerRe: Merge two pdf files into one Pin
Richard MacCutchan14-Jan-10 21:36
mveRichard MacCutchan14-Jan-10 21:36 
AnswerRe: Merge two pdf files into one Pin
Steven J Jowett15-Jan-10 1:38
Steven J Jowett15-Jan-10 1:38 
GeneralRe: Merge two pdf files into one Pin
C#Coudou15-Jan-10 13:51
C#Coudou15-Jan-10 13:51 
QuestionCreating desktop Icon ! Pin
jeshra27914-Jan-10 17:49
jeshra27914-Jan-10 17:49 
AnswerRe: Creating desktop Icon ! Pin
Dave Kreskowiak14-Jan-10 18:14
mveDave Kreskowiak14-Jan-10 18:14 
QuestionHow to Decrypt an MD5'd password using a textbox and a button... Pin
thebiostyle14-Jan-10 11:20
thebiostyle14-Jan-10 11:20 
AnswerRe: How to Decrypt an MD5'd password using a textbox and a button... Pin
EliottA14-Jan-10 11:29
EliottA14-Jan-10 11:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.