嗨,我想發送電子郵件在wpf應用程序,但我卡住了; 我展示我的XAML代碼發送電子郵件與wpf
<Grid>
<Button Style="{DynamicResource ShowcaseRedBtn}" CommandParameter="[email protected]" Tag="Send Email" Content="Button" Height="23" HorizontalAlignment="Left" Margin="351,186,0,0" Name="button1" VerticalAlignment="Top" Width="140" Click="button1_Click" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="92,70,0,0" Name="txtSubject" VerticalAlignment="Top" Width="234" />
<TextBox AcceptsReturn="True" AcceptsTab="True" Height="159" HorizontalAlignment="Left" Margin="92,121,0,0" Name="txtBody" VerticalAlignment="Top" Width="234" />
</Grid>
這裏在後面的代碼:
private void button1_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
if (btn == null)
return;
string url = btn.CommandParameter as string;
if (String.IsNullOrEmpty(url))
return;
try
{
// here i wish set the parameters of email in this way
// 1. mailto = url;
// 2. subject = txtSubject.Text;
// 3. body = txtBody.Text;
Process.Start("mailto:[email protected]?subject=Software&body=test ");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
我的目的是設置電子郵件結合從表單中的數據的參數: // 1.郵寄地址=網址; // 2. subject = txtSubject.Text; // 3. body = txtBody.Text;
你知道如何解決這一步嗎?
非常感謝您的關注。
乾杯
一個的Process.Start()與 「電子郵件地址:」 URL將打開用戶郵件客戶端使用新的預填充消息。那是你要的嗎 ?或者當你按下按鈕時你真的想發送郵件嗎? – JYL 2011-01-21 10:58:14