Click here to Skip to main content
15,905,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to send an email on click of a button. I have fromaddress and toaddess. Is there a away to send the email without password of fromaddress?
Posted

Possible only for local Network not for Internet or i will say that we can not use
Yahoo or Gmail or whatever account is there without password to send email in our application[ Security reasons ] .
 
Share this answer
 
YOu need the SMTP sever details for sending the mail.

VB
Private Sub SendMail(ByVal StrTo As String, ByVal StrFrom As String, ByVal Subject As String, ByVal body As String)
      Try
          Dim msgMail As New MailMessage
          Dim mailclient As New SmtpClient
          Dim toadd As New MailAddressCollection
          Dim fromAddress As New MailAddress(StrFrom)
          If StrTo.Trim = "" Or StrFrom.Trim = "" Then
              Response.Write("<script language='javascript'>alert('No Email found')</script>")
              Exit Sub
          End If
          toadd.Add(StrTo)

          msgMail.To.Add(toadd.ToString)
          msgMail.From = fromAddress

          msgMail.Subject = Subject
          msgMail.Body = Server.HtmlDecode(body)
          msgMail.IsBodyHtml = True

          Dim contentId As String = "imgBand"  'This content id is used in HTML with prefix "cid:"
          Dim path As String = Server.MapPath("~") & "\"
          Dim filename As String = path & "Images/imageFunction5.png"
          Dim av1 As AlternateView
          'To create alternate view for Email
          'Images can be embedded using alternate view
          av1 = AlternateView.CreateAlternateViewFromString(body, Nothing, MediaTypeNames.Text.Html)
          'Linking the Band(Image) with the Email content
          Dim linkedResource As LinkedResource = New LinkedResource(filename)
          linkedResource.ContentId = contentId
          linkedResource.ContentType.Name = filename
          av1.LinkedResources.Add(linkedResource)
          filename = path & "Images/Test logo.gif"
          contentId = "imgLogo"
          'Linking the Logo (Image)with the Email content
          Dim linkedResource_img As LinkedResource = New LinkedResource(filename)
          linkedResource_img.ContentId = contentId
          linkedResource_img.ContentType.Name = filename
          av1.LinkedResources.Add(linkedResource_img)
          msgMail.AlternateViews.Add(av1)

              mailclient.Host = '"mailhost-sghq.test.net" '"172.1.2.2"
              mailclient.Send(msgMail)
                       Exit Sub
          End If
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900