在函数中循环内发送电子邮件

时间:2015-06-25 20:18:34

标签: vb.net email

代码正在构建电子邮件,但只有六个时才会显示一行。我在文本文件上得到了正确的答案,但我需要它在电子邮件中执行相同的操作。我想我在错误的位置得到了下一个声明。这是我遇到问题的代码示例。我不知道如何在不中断vbLine

的情况下放置下一个语句
        For Each p In query
            If p.Contract_No IsNot Nothing Then
                ContractNo = p.Contract_No
            Else
                ContractNo = " "
            End If
            If p.Vendor_Name IsNot Nothing Then
                VenderName = p.Vendor_Name
            Else
                VenderName = " "
            End If
            If p.Termination_Date IsNot Nothing Then
                TerminationDate = p.Termination_Date
                '   ReportDateStr = ReportDate.ToString
                TerminationDateStr = String.Format("{0:MM/dd/yyyy}", TerminationDate)
            Else
                TerminationDateStr = " "
            End If
            If p.Dept_Name IsNot Nothing Then
                DeptName = p.Dept_Name
            Else
                DeptName = " "
            End If
            If p.Renewal_Option_Desc IsNot Nothing Then
                RenewalOption = p.Renewal_Option_Desc
            Else
                RenewalOption = " "
            End If
            If p.Contract_Desc IsNot Nothing Then
                ContractDesc = p.Contract_Desc
            Else
                ContractDesc = " "
            End If
            If p.Contact_Email IsNot Nothing Then
                ContactEmail = p.Contact_Email
            Else
                ContactEmail = "** N/A ** "
            End If



            ' sends email with attachment
            EmailMsgBody = "-- TOTAL # OF CONTRACTS WITH FAILSAFE DATE ON " + DateStr + " IS: " + icnt.ToString + vbCrLf +
            vbNewLine + "                                                                                                                                                 __________________                                                                                     " +
            vbNewLine +
            vbNewLine + "                                                                                                                                                 *****Contracts****                                                                                     " +
            vbNewLine + "                                                                                                                                                 __________________                                                                                     " +
            vbNewLine +
            vbNewLine + "Contract#" + "             " + "Vender Name" + "                                  " + "Termination Date" + "     " + "Dept Name" + "                                " + "Renewal Option" + "                      " + "Contract Desc" + "                                  " + "Email Address" +
            vbNewLine + "------------" + "             " + "-----------------" + "                                  " + "---------------------" + "     " + "--------------" + "                                " + "--------------------" + "                      " + "-----------------" + "                                  " + "-----------------" +
            vbNewLine + ContractNo.PadRight(18) + "  " + _
                VenderName.PadRight(38) + " " + _
                 TerminationDateStr.PadRight(26) + " " + _
                 DeptName.PadRight(27) + " " + _
                  RenewalOption.PadRight(45) + "   " + _
                 ContractDesc.PadRight(32) + "   " + _
                 ContactEmail.PadRight(11) + "  "

0 个答案:

没有答案