CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Location
    Pakistan(Skardu)
    Posts
    64

    Question 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", "Manoj@geinetech.net")
    '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)

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: send email vb.net

    Do you get any error messages? Simply saying it does not work is not helpful.

  3. #3
    Join Date
    Dec 2004
    Location
    Pakistan(Skardu)
    Posts
    64

    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

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Jan 2009
    Posts
    2

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured