Advertisement
Guest User

MAIL

a guest
Jun 7th, 2018
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.67 KB | None | 0 0
  1. 'OBTENER IMAGEN
  2. Public Class Form1
  3.     Dim b As Bitmap
  4.     Sub New()
  5.         ' This call is required by the designer.
  6.         InitializeComponent()
  7.         ' Add any initialization after the InitializeComponent() call.
  8.         b = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
  9.         ScreenCapturePanel.Image = b
  10.     End Sub
  11.  
  12.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  13.         If b IsNot Nothing Then
  14.             Dim g As Graphics = Graphics.FromImage(b)
  15.             g.CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, New Point(0, 0), Screen.PrimaryScreen.Bounds.Size)
  16.             Cursor.Draw(g, New Rectangle(Cursor.Position, Cursor.Size))
  17.             g.Dispose()
  18.             Me.Refresh()
  19.         End If
  20.     End Sub
  21. End Class
  22.  
  23. 'ENVIARLA
  24. Imports EASendMail 'Add EASendMail namespace
  25. Module Module1
  26.     Sub Main()
  27.         Dim oMail As New SmtpMail("TryIt")
  28.         Dim oSmtp As New SmtpClient()
  29.         ' Set sender email address, please change it to yours
  30.         oMail.From = "test@emailarchitect.net"
  31.  
  32.         ' Set recipient email address, please change it to yours
  33.         oMail.To = "support@emailarchitect.net"
  34.  
  35.         ' Set email subject
  36.         oMail.Subject = "test HTML email with embedded image"
  37.  
  38.         ' Your SMTP server address
  39.         Dim oServer As New SmtpServer("smtp.emailarchitect.net")
  40.  
  41.         ' User and password for ESMTP authentication, if your server doesn't require
  42.         ' User authentication, please remove the following codes.
  43.         oServer.User = "test@emailarchitect.net"
  44.         oServer.Password = "testpassword"
  45.  
  46.         ' If your smtp server requires SSL/TLS connection, please add this line
  47.         ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
  48.         Try
  49.             ' Add image attachment from local disk
  50.             Dim oAttachment As Attachment = oMail.AddAttachment("d:\test.gif")
  51.  
  52.             ' Specifies the attachment as an embedded picture
  53.             ' contentid can be any string.
  54.             Dim contentID As String = "test001@host"
  55.             oAttachment.ContentID = contentID
  56.             oMail.HtmlBody = "<html><body>this is a <img src=""cid:" _
  57.                      + contentID + """> embedded picture.</body></html>"
  58.  
  59.             Console.WriteLine("start to send email with embedded image ...")
  60.             oSmtp.SendMail(oServer, oMail)
  61.             Console.WriteLine("email was sent successfully!")
  62.         Catch ep As Exception
  63.             Console.WriteLine("failed to send email with the following error:")
  64.             Console.WriteLine(ep.Message)
  65.         End Try
  66.     End Sub
  67. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement