locked
send e-mail with microsoft outlook

    السؤال

  • My program worked to send -email using Lotus notes, but know they have give us Microsoft outlook 2007 to use, my code does not work now.

    #Region "send mail funcsion Overbookings"
        Private Sub funcOverbookings()
            Try
                'create the mail message
                Dim MyMail As New MailMessage()
    
                'set the addresses
                MyMail.From = New MailAddress("hen@aaa.co.za", "Hen")
                MyMail.To.Add(New MailAddress("cprtdtops@aaa.co.za", "Cptadt Ops"))
     
                'set the content
                Dim dttDate As DateTime = DateTime.Now 'Hoe jy dit gewys wil hê
                Dim myyFormat As String = "  dd MMM yyyy"  'Verander die Dag en Maand na Afrikaans
                MyMail.Subject = dttDate.ToString(myyFormat) + "  Overbookings.pdf file"
                '  Thread.CurrentThread.CurrentCulture = New CultureInfo("es-us")
    
                Dim sr As New StreamReader("C:\Do_It\Overbookings.txt")
                'Dim sr As New StreamReader("C:\Batfiles\Overbookings.html")
                Dim body As String = sr.ReadToEnd()
                sr.Close()
    
                MyMail.Body = body
                'MyMail.IsBodyHtml = True
                'Create the SMTPClient object and specify the SMTP server name or IP Address
    
                'MyMail.Headers.Add("Disposition-Notification-To", "<hen@aaa.co.za>")
                MyMail.Attachments.Add(New Attachment(CurDir() & "\Overbookings.pdf"))
    
                Dim SMTPServer As New SmtpClient("192.211.12.463")
    
                SMTPServer.Send(MyMail)
    
                Dim str As String = "Email is te volle gestuur na:" & vbCrLf & vbCrLf
                str &= "To: " & MyMail.To.ToString() & vbCrLf & vbCrLf
                str &= "CC: " & MyMail.CC.ToString() & vbCrLf & vbCrLf
                str &= "BCC: " & MyMail.Bcc.ToString()
                Cls_MessageBbox.Show(str, "Overbookings")
            Catch ex As Net.Mail.SmtpException
                Cls_MessageBbox.Show(ex.Message.ToString, "Kan email nie stuur nie.")
            End Try
        End Sub
    


    02/ذو القعدة/1432 05:40 ص

الإجابات