daniel50096230
July 22nd, 2009, 03:51 AM
I have the following code to send email
For Each aaaa In array1
Try
'LoadConfiguration()
'Get_GroupCode("INVT.DIH02", DistID)
'GetRecipientAddress("DM", DistID) ' Select from tb_user - Dist
GetDistEmail(aaaa)
GetDistName(array1(abd))
Dim oMsg As New MailMessage()
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SenderAddress)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SenderPassword)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", MailServer)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 10)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
oMsg.From = DisplayID
oMsg.To = RecipientAddress
oMsg.Cc = RecipientCCAddress
'oMsg.Bcc = strBCC
oMsg.Subject = "Inventory Data - Missing/Incorrect Barcode"
oMsg.BodyFormat = MailFormat.Html
oMsg.Body = "<HTML><HEAD><style>.Bd1 { FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Verdana; TEXT-ALIGN: LEFT } "
oMsg.Body &= "</style></HEAD><BODY class=Bd1>"
oMsg.Body &= "Items with Missing/Incorrect Barcode Notification<br /><br />"
oMsg.Body &= "Sender Name : " + DistName + "<br />"
oMsg.Body &= "File Type : Inventory Data <br />"
oMsg.Body &= "Transmission Date/Time : " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") + "<br />"
oMsg.Body &= "Transmission Number : " + array1(abd) + "<br />"
oMsg.Body &= "No of items with Missing/Incorrect Barcode : " + array2(abd).ToString() + "<br /><br />"
oMsg.Body &= "The submitted file has item(s) with missing/incorrect barcode or there are missing EAN Product Code. The processing of the submitted file is pending J&J's acknowledgement and correction."
oMsg.Body &= "</BODY></HTML>"
SmtpMail.SmtpServer = MailServer
SmtpMail.Send(oMsg)
oMsg = Nothing
abd += 1
Catch ex As Exception
End Try
Next
But the funny thing is after I send the first email, when the for loop still have value,the email cannot be send anymore and it cause duplicate data into database.
But when I remove the above codes, the program works well.
Anyone know what is the problem?
For Each aaaa In array1
Try
'LoadConfiguration()
'Get_GroupCode("INVT.DIH02", DistID)
'GetRecipientAddress("DM", DistID) ' Select from tb_user - Dist
GetDistEmail(aaaa)
GetDistName(array1(abd))
Dim oMsg As New MailMessage()
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SenderAddress)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SenderPassword)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", MailServer)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 10)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
oMsg.From = DisplayID
oMsg.To = RecipientAddress
oMsg.Cc = RecipientCCAddress
'oMsg.Bcc = strBCC
oMsg.Subject = "Inventory Data - Missing/Incorrect Barcode"
oMsg.BodyFormat = MailFormat.Html
oMsg.Body = "<HTML><HEAD><style>.Bd1 { FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Verdana; TEXT-ALIGN: LEFT } "
oMsg.Body &= "</style></HEAD><BODY class=Bd1>"
oMsg.Body &= "Items with Missing/Incorrect Barcode Notification<br /><br />"
oMsg.Body &= "Sender Name : " + DistName + "<br />"
oMsg.Body &= "File Type : Inventory Data <br />"
oMsg.Body &= "Transmission Date/Time : " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") + "<br />"
oMsg.Body &= "Transmission Number : " + array1(abd) + "<br />"
oMsg.Body &= "No of items with Missing/Incorrect Barcode : " + array2(abd).ToString() + "<br /><br />"
oMsg.Body &= "The submitted file has item(s) with missing/incorrect barcode or there are missing EAN Product Code. The processing of the submitted file is pending J&J's acknowledgement and correction."
oMsg.Body &= "</BODY></HTML>"
SmtpMail.SmtpServer = MailServer
SmtpMail.Send(oMsg)
oMsg = Nothing
abd += 1
Catch ex As Exception
End Try
Next
But the funny thing is after I send the first email, when the for loop still have value,the email cannot be send anymore and it cause duplicate data into database.
But when I remove the above codes, the program works well.
Anyone know what is the problem?