Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Blat or MailMessage()
Message
From
02/09/2011 11:25:56
 
 
To
30/08/2011 16:34:21
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01522297
Message ID:
01522589
Views:
30
>>>>>>>Hi,
>>>>>>>
>>>>>>>I'm using VS2008 and C# (what version of C# is that?) and need to send an email with an attachment from my ASP.NET solution.
>>>>>>>
>>>>>>>I've recently started using Blat.dll in VFP and find it nice and easy to use, should I use it in my .NET stuff or should I use MailMessage()
>>>>>>>
>>>>>>>If using blat, does anyone have some example code?
>>>>>>
>>>>>>I've never used Blat but, FWIW, I have a simple assembly using the System.Net.Mail .MailMessage and .SmtpClient classes. I've plugged it in to various applications for various clients over the years and have yet to encounter any problems.......
>>>>>
>>>>>
>>>>>Thanks Viv,
>>>>>
>>>>>could you share your code, please?
>>>>
>>>>Just looked at it. It is so embarrassingly crude (cobbled together at least five years ago on the spur of the moment and never revisited) that I think I'll just PM it to you :-}
>>>
>>>Thanks, I'm sure it won't be as crude as what I have come up with :)
>>
>>Wanna bet ? Anyone it is on it's way.....
>
>Thanks Viv!

The core of it boils down to this:
System.Net.Mail.SmtpClient mailclient = new System.Net.Mail.SmtpClient("ServerName");
            mailclient.Credentials = new System.Net.NetworkCredential("UserName", "Password");

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("SendersAddress","RecipientsAddress");
            msg.Subject = "Message Subject";
            msg.Body = "This is the body of the message";

            mailclient.Send(msg);
There are bits to add names to the send list, add attachments etc but.......
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform