-
send email vb.net
Hi Expert,
I have a program that send email...but It would not send a mail in a sender sent item..code is below
SmtpMail.SmtpServer = txtSMTPServer.Text
'Multiple recepients can be specified using ; as the delimeter
Mailmsg.To = txtTo.Text
Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"
'Specify the body format
If chkFormat.Checked = True Then
Mailmsg.BodyFormat = MailFormat.Html 'Send the mail in HTML Format
Else
Mailmsg.BodyFormat = MailFormat.Text
End If
'If you want you can add a reply to header
'Mailmsg.Headers.Add("Reply-To", "[email protected]")
'custom headersare added like this
'Mailmsg.Headers.Add("Manoj", "TestHeader")
Mailmsg.Subject = txtSubject.Text
For Counter = 0 To lstAttachment.Items.Count - 1
Attachment = New MailAttachment(lstAttachment.Items(Counter))
Mailmsg.Attachments.Add(Attachment)
Next
Mailmsg.Body = txtMessage.Text
SmtpMail.Send(Mailmsg)
-
Re: send email vb.net
Do you get any error messages? Simply saying it does not work is not helpful.
-
Re: send email vb.net
it is working...it just send email...but not a copy in sender 's sent box folder
thanx for reply
-
Re: send email vb.net
The thing here is it's using the smtp setting from the mail proggy (Outlook) to send the email directly to the mail server, and not the proggy itself..
to have the sender keep a copy of the mail .. i'd simply CC it the sender address..
Gremmy...
-
Re: send email vb.net
Hi,
I am trying to use the same code as above but also have errors. Im not very advanced with dot net however I am trying.
My errors:
obj.SmtpServer = txtSMTPServer.Text
Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"
Mailmsg.BodyFormat = MailFormat.Html
Mailmsg.BodyFormat = MailFormat.Text
Attachment = New MailAttachment(lstAttachment.Items(Counter))
Errors say:
Some of the code is obselete it says others say:
Value of type 'System.Web.Mail.MailAttachment' cannot be converted to 'System.Net.Mail.Attachmeny'
Do I import both Imports System.Net.Mail and Imports System.web.Mail??
Any help would be great. Im using 2008 version too.