在邮件正文中添加多个选定的日历日期wpf c#

时间:2016-01-11 09:08:33

标签: c# wpf email

在MyCalendar_SelectedDatesChanged()事件中,我在列表框中显示所有多个选定日期。我需要选择所有这些日期并逐行添加电子邮件。 发送邮件代码:

NSMutableDictionary *networks; //Key: MAC Address (BSSID)

    void *libHandle;
    void *airportHandle;    
    int (*apple80211Open)(void *);
    int (*apple80211Bind)(void *, NSString *);
    int (*apple80211Close)(void *);
    int (*associate)(void *, NSDictionary*, NSString*);
    int (*apple80211Scan)(void *, NSArray **, void *);



 - (id)init
{
    self = [super init];

    networks = [[NSMutableDictionary alloc] init];
    libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);
//   libHandle = dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", RTLD_LAZY);
//   libHandle = dlopen("/System/Library/PrivateFrameworks/MobileWiFi.framework/MobileWiFi", RTLD_LAZY);

    char *error;
    if (libHandle == NULL && (error = dlerror()) != NULL)  {
        NSLog(@"err ...r%s",error);
        exit(1);
    }
    else{
        NSLog(@"not null");
    }


    apple80211Open = dlsym(libHandle, "Apple80211Open");
    apple80211Bind = dlsym(libHandle, "Apple80211BindToInterface");
    apple80211Close = dlsym(libHandle, "Apple80211Close");
    apple80211Scan = dlsym(libHandle, "Apple80211Scan");
    applecopy= dlsym(libHandle,  "Apple80211GetInfoCopy");
    apple80211Open(&airportHandle);
    apple80211Bind(airportHandle, @"en0");
    return self;
}

如何在c#wpf中添加html格式所需的正文??

1 个答案:

答案 0 :(得分:0)

尝试以下可能对您有帮助的代码。

login = new NetworkCredential("wapsatest@gmail.com", "wapsatest123456");
client = new SmtpClient("smtp.gmail.com");
client.Port = Convert.ToInt32(587);
client.EnableSsl = true;
client.Credentials = login;
msg = new MailMessage { From = new MailAddress("wapsatest" + "smtp.gmail.com".Replace("smtp.", "@"), "nWorks Employee", Encoding.UTF8) };
msg.To.Add(new MailAddress("saurabh.pawar@nworks.co"));
msg.Subject = "Requested for leave by "+comboboxEmployee.Text;

//-------------------Code for your Email body---------------------
string strBody = string.Empty;
int i = 1;
strBody += "///////////////List of dates coming from list box name selecteddates";
strBody += Environment.NewLine;
foreach (var item in lstDate)  // here "lstDate" is name of your list where you store all date.
{
    //strBody += item.ToShortDateString() + Environment.NewLine;
    strBody += "Some text before date".
    strBody += i + ". " + item.ToShortDateString() + " (" + item.DayOfWeek + ")";
    strBody += "Some text after date".
    strBody += "<br/>";
    i++;
}
msg.Body = strBody;
//----------------------------- Over -----------------------------

msg.BodyEncoding = Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.Normal;
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userstate = "sending.......";
client.SendAsync(msg, userstate);