Hey,
I don't know if the attachment isn't being sent, I just not that it doesn't
arrive along with the email. I get the email in my inbox but without the
attachment. The only thing I pass to the function is a string, so that
shouldn't be an issue. Here is the complete code of the class I wrote
using System;
using System.Collecti ons;
using System.Web;
using System.Web.Mail ;
using System.Text;
using System.Configur ation;
namespace PT_proj1
{
/// <summary>
/// Summary description for Mail.
/// </summary>
public class Mail
{
private MailMessage message;
private string afzender;
private string smtpServer;
public Mail (string afz, string smtp)
{
message = new MailMessage();
this.afzender = afz;
this.smtpServer = smtp;
}
public void VulMail (ArrayList ontvangers, ArrayList cc,
string onderwerp, string tekst)
{
cc.Add(this.afz ender);
message = new MailMessage();
message.From = afzender;
message.Body = tekst;
message.Subject = onderwerp;
message.BodyEnc oding = Encoding.ASCII;
foreach(string adres in ontvangers)
{
if (message.To != "") message.To += ", ";
message.To += adres;
}
foreach(string adres in cc)
{
if (message.Cc != "") message.Cc += ", ";
message.Cc += adres;
}
}
public void AddAttachment (string file)
{
MailAttachment bijlage = new MailAttachment( file,MailEncodi ng.Base64);
if (!message.Attac hments.Contains (bijlage))
{
message.Attachm ents.Add(bijlag e);
}
}
public void VerstuurMail()
{
if (smtpServer != null)
{
System.Web.Mail .SmtpMail.SmtpS erver = smtpServer;
System.Web.Mail .SmtpMail.Send( message);
}
}
}
}
"rk" <kr*****@hotmai l.com> schreef in bericht
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
Your function looks alright. How do you know that the attachment is
not being sent? Have you inspected the message right before send to
see if the attachment is still there? Since you have not put the
complete code it is difficult to diagnose the issue. It might be
problem where a local copy of the object is passed thru an argument
and thus losing all the changes when it finally gets out of the
function, but it is still a guess.