"Howard" <no****@home.please.co.uk> wrote in message news:Wa********************@pipex.net...
thank you, even better !
I don't suppose you could show me how to add word document attachment as
well.
The plain text version that my code generates is not so good and needs
coping and pasting into a word proforma at the other end. It would be better
if I could build up the word doc directly from VB and then email it as an
attachment.
Howard
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim myTo As MailAddress, myFrom As MailAddress
Dim myClient As SmtpClient, myMessage As MailMessage
'A simple message
myMessage = New MailMessage("Person1_AT_mail_DOT_com", "Person2_AT_mail_DOT_com", _
"This is the simple subject", "This is the simple body")
myClient = New SmtpClient("smtp.server.net")
myClient.Send(myMessage)
'A more complex example
myTo = New MailAddress("Person1_AT_mail_DOT_com", "FirstNameA SecondNameA")
myFrom = New MailAddress("Person2_AT_mail_DOT_com", "FirstNameB SecondNameB")
myMessage = New MailMessage(myFrom, myTo)
myMessage.IsBodyHtml = True
myMessage.To.Add("Person3_AT_mail_DOT_com")
myMessage.Bcc.Add("Person4_AT_mail_DOT_com")
myMessage.Body = ("<B>This is the body</B>")
myMessage.Subject = ("This is the subject")
myMessage.Attachments.Add(New Attachment("C:\MyLargeImage1.bmp"))
myMessage.Attachments.Add(New Attachment("C:\MyLargeImage2.bmp"))
myMessage.Attachments.Add(New Attachment("C:\MySmallImage1.bmp"))
myMessage.Attachments.Add(New Attachment("C:\MySmallImage2.bmp"))
'myClient = New SmtpClient("smtp.server.net")
myClient.Send(myMessage)
End Sub