Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Using an Alternative FROM Address for SMTP
Demonstrates how to call SendMime instead of SendEmail to pass a FROM address and RCPT TO addresses that are different than what is specified in the email header. // Demonstrates how to call SendMime so that the FROM address in the
// MIME header may be different than the FROM address passed to the SMTP server
// during the SMTP protocol conversation.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("anything for 30-day trial");
mailman.SmtpHost = "smtp.comcast.net";
Chilkat.Email email = new Chilkat.Email();
email.Subject = "Subject for C# email example";
email.Body = "Body for C# email example code";
email.AddTo("Chilkat Admin", "admin@chilkatsoft.com");
email.AddFileAttachment("someFile.pdf");
// Normally, when SendEmail is called, the FromAddress
// is passed to the SMTP server as the argument to the FROM
// command (during the SMTP protocol conversation).
// It is also the address found in the "From" MIME header field
// of the email.
email.FromName = "Chilkat Support";
email.FromAddress = "support@chilkatsoft.com";
// In this example, we'll send the email by calling mailman.SendMime
// This allows us to provide recipients and a "From" address that may
// be different than what is in the MIME header of the email.
string mime = email.GetMime();
string recipientList;
string smtpFrom;
smtpFrom = "joe@mycompany.com";
recipientList = "admin@chilkatsoft.com, support@chilkatsoft.com";
// The "joe@mycompany.com" will appear in the "Received" header field
// of the email, like this:
/*
* Received: from unknown (HELO ****.comcast.net) ([206.18.177.52])
(envelope-sender <joe@mycompany.com>)
by ****.com (qmail-ldap-1.03) with SMTP
for <admin@chilkatsoft.com>; 5 Aug 2006 02:06:19 -0000
*/
bool success = mailman.SendMime(smtpFrom, recipientList, mime);
if (!success)
{
MessageBox.Show(mailman.LastErrorText);
}
else
{
MessageBox.Show("Mail Sent!");
}
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.