[英]How can I search for a string say “xyz” in the pixel value's of an image using c# or Vb.net
[英]how can i send a canvas image using vb.net email
我使用canvg将SVG转换为画布,然后转换为图像,然后在vb.net客户端将图像转换为bytearray()并将其保存到服务器上的文件夹中,这样我就可以通过电子邮件进行附加:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim path = Server.MapPath("PDFs\")
Dim fileNameWithPath As String = path + DateTime.Now.ToString().Replace("/", "-").Replace(" ", "-").Replace(":", "") + ".jpeg"
Dim fs As FileStream = New FileStream(fileNameWithPath, FileMode.Create)
Dim bw As BinaryWriter = New BinaryWriter(fs)
Dim ByteArray() As Byte = Convert.FromBase64String(hfChartImg.Value)
bw.Write(ByteArray)
bw.Close()
Dim file As String = fileNameWithPath
Dim message As New MailMessage()
message.From = New MailAddress("****************")
message.To.Add(New MailAddress("***************"))
message.Subject = "new image "
message.Body = "this is the apak chart img"
Dim data As New Attachment(file)
message.Attachments.Add(data)
Dim client As New SmtpClient()
client.Host = "smtp.gmail.com"
client.Credentials = New NetworkCredential("***************", "*******")
client.EnableSsl = True
client.Port = 587
client.Send(message)
End Sub
此代码可以正常工作,并发送图像。
实际上,我不需要将此图像保存到我的服务器上,我只想发送它而不保存,这是我到目前为止所做的
Protected Sub emailSend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles emailSend.Click
Dim customerChoice As String = DropDownList1.Text
Select Case customerChoice
Case "pdf"
MsgBox("select pdf ")
Case "image"
Dim imageFile As MemoryStream = New MemoryStream()
Dim bw As BinaryWriter = New BinaryWriter(imageFile)
Dim bytearray() As Byte = Convert.FromBase64String(hfChartImg.Value)
bw.Write(bytearray)
我距离我要做的事情很远吗?
您正在尝试写
Dim data As New Attachment(New MemoryStream(ByteArray), "SomeName")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.