Sends an e-mail message with raw content.
[Visual Basic]
Public Sub SendRawMail( _
server As SmtpServer, _
mail() As Byte, _
from As MailAddress, _
recipients As AddressCollection _
)
[C#]
public void SendRawMail(
SmtpServer server,
byte[] mail,
MailAddress from,
AddressCollection recipients
);
[C++]
public: void SendRawMail(
SmtpServer^ server,
array<unsigned char>^ mail,
MailAddress^ from,
AddressCollection^ recipients
);
[JScript]
public function SendRawMail(
server : SmtpServer,
mail : Byte[],
from : MailAddress,
recipients : AddressCollection
);
Parameters
Remarks
Example
[Visual Basic, C#] To get the full samples of EASendMail, please refer to Samples section.
[VB - Forward Email]
Imports EASendMail
Imports System.IO
Sub ForwardEmailFile()
Try
Dim from As New MailAddress("from@adminsystem.com")
Dim recipients As New AddressCollection("to@adminsystem.com")
Dim fs As New FileStream("c:\test.eml", FileMode.Open, FileAccess.Read, FileShare.Read)
Dim mailData(fs.Length - 1) As Byte
fs.Read(mailData, 0, fs.Length)
fs.Close()
Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
' SMTP user authentication
oServer.User = "myusername"
oServer.Password = "mypassword"
' Most mordern SMTP servers require SSL/TLS connection now.
' ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically.
oServer.ConnectType = SmtpConnectType.ConnectTryTLS
Dim oSmtp As SmtpClient = New SmtpClient
oSmtp.SendRawMail(oServer, mailData, from, recipients)
Catch exp As Exception
Console.WriteLine("Exception: {0}", exp.Message)
End Try
End Sub
[C# - Forward Email]
using System;
using EASendMail;
using System.IO;
void ForwardEmailFile()
{
try
{
MailAddress from = new MailAddress("from@adminsystem.com");
AddressCollection recipients = new AddressCollection("to@adminsystem.com");
FileStream fs = new FileStream("c:\\test.eml", FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] mailRawData = new byte[fs.Length];
fs.Read(mailRawData, 0, mailRawData.Length);
fs.Close();
SmtpServer oServer = new SmtpServer("myserveraddress");
// SMTP user authentication
oServer.User = "myusername";
oServer.Password = "mypassword";
// Most mordern SMTP servers require SSL/TLS connection now.
// ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically.
oServer.ConnectType = SmtpConnectType.ConnectTryTLS;
SmtpClient oSmtp = new SmtpClient();
oSmtp.SendRawMail(oServer, mailRawData, from, recipients);
}
catch (Exception exp)
{
Console.WriteLine("Exception: {0}", exp.Message);
}
}
See Also
SmtpClient.SendMail Method
SmtpClient.BeginSendMail Method
SmtpClient.BeginSendRawMail Method
Work with EASendMail Service (Email Queuing)
SmtpClient.SendMailToQueue Method
SmtpClient.SendMailToQueueEx Method
Online Tutorials
Send Email
in VB 6.0 - Tutorial
Send
Email in C# - Tutorial
Send
Email in VB.NET - Tutorial
Send Email
in Visual C++ - Tutorial
Send Email in Managed C++/CLI - Tutorial
Send
Email in Delphi - Tutorial
Send
Email in MS SQL stored procedure - Tutorial