- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Windows Mobile 应用程序的新手。在我的项目中,我想使用 microsoft.windowsmobile.pocketoutlook
发送电子邮件。到目前为止,我有以下代码:
private void btnsubmit_Click(object sender, EventArgs e)
{
try
{
totleave();
OutlookSession ol = new OutlookSession();
EmailMessage em = new EmailMessage();
//Recipient s1 = em.From;
//Console.WriteLine(s1);
Recipient r = new Recipient("iyalarasi.r", "iyalarasi.r@winxsolutions.com");
em.To.Add(r);
em.Subject = "Request For Leave";
em.BodyText =txtename.Text +"(Emp id:"+txteno.Text+ ")" + " request "+ cb1.SelectedItem.ToString()+" leave from "+dtpfrom .Value
.ToShortDateString ()+" to "+dtpto .Value.ToShortDateString () + "\n The reason is " + txtreason.Text;
EmailAccount ea = ol.EmailAccounts[0];
ea.Send(em);
// em.Send("iyalarasi.r");//Account name in outlook
//MessagingApplication.Synchronize("iyalarasi.r");
MessageBox.Show("mail sent");
f2.Show();
f2.lblmsg.Text = "You have Applied Leave";
}
catch (PocketOutlookException ex)
{
lblmsg1.Text = ex.ToString();
}
catch (Exception e1)
{
lblmsg1.Text = e1.ToString();
}
}
使用此代码,电子邮件会出现在发件箱中,但绝不会出现在收件箱中。使用 Gmail,它显示以下消息:
Messages could not be sent. Check that you have network coverage, and that your account information is correct, and then try again.
我的帐户信息是正确的。这是怎么回事?
最佳答案
我已经使用 POOM 从 Windows Mobile 设备发送电子邮件:
我使用代码遍历可用的 Outlook 电子邮件帐户。字符串 sMailAccount 具有 pocketOutlook 中显示的帐户名称,例如“Google Mail”:
sendMail类的类代码...
public sendMail(string sMailAccount)
{
session = new OutlookSession();
//eMail = new EmailMessage();
bool bFound = false;
foreach (Account acc in session.EmailAccounts)
{
System.Diagnostics.Debug.WriteLine(acc.Name);
if (acc.Name == sMailAccount)
bFound = true;
}
if (bFound)
account = session.EmailAccounts[sMailAccount];
if (account != null)
_bIsValidAccount = true;
}
...
我的代码用于向收件人发送图像:
public bool send(string sImagePath)
{
if (account == null)
return false;
try
{
eMail = new EmailMessage();
rcp = new Recipient(_to);
eMail.To.Add(rcp);
eMail.Subject = "Visitenkarten";
eMail.BodyText = "VCard " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\r\nsent from eMDI2Mail";
attachement = new Attachment(sImagePath);
eMail.Attachments.Add(attachement);
eMail.Send(account);
//account.Send(eMail);
if (this._syncImmediately)
{
if (this.account != null)
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
}
return true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Exception in send(): " + ex.Message);
}
return false;
}
另一个需要了解的问题是 POutlook 不会立即发送消息。为此,我引入了一个名为 _syncImmediately 的变量。如果是这样,Outlook 将立即发送邮件。如果没有,我提供另一个名为 syncNow() 的函数:
/// <summary>
/// sync eMail in outlook
/// </summary>
/// <param name="pHandle">handle to forground window</param>
public void syncNow(IntPtr pHandle)
{
if (this.account != null)
{
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
SetForegroundWindow(pHandle);
}
}
SetForeGroundWindow() 用于将我们带回应用程序。
这是全类:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.WindowsMobile.PocketOutlook;
namespace eMdiMail
{
class sendMail:IDisposable
{
[DllImport("coredll", EntryPoint = "SetForegroundWindow")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
OutlookSession session;
public EmailAccount account;
EmailMessage eMail;
public String _to = "TheRecipient@intermec.com";
Attachment attachement;
Recipient rcp;
bool _syncImmediately = false;
public bool syncImmediately
{
get { return _syncImmediately; }
set { _syncImmediately = value; }
}
bool _bIsValidAccount = false;
public bool bIsValidAccount
{
get
{
return _bIsValidAccount;
}
}
public bool setAccount(string sMailAccount)
{
session.Dispose();
session = new OutlookSession();
//eMail = new EmailMessage();
bool bFound = false;
foreach (Account acc in session.EmailAccounts)
{
if (acc.Name == sMailAccount)
{
account = session.EmailAccounts[sMailAccount];
bFound = true;
}
}
return bFound;
}
public sendMail(string sMailAccount)
{
session = new OutlookSession();
//eMail = new EmailMessage();
bool bFound = false;
foreach (Account acc in session.EmailAccounts)
{
System.Diagnostics.Debug.WriteLine(acc.Name);
if (acc.Name == sMailAccount)
bFound = true;
}
if (bFound)
account = session.EmailAccounts[sMailAccount];
else
{
if(this.createAccountGoogle())
account = session.EmailAccounts[sMailAccount];
}
if (account != null)
_bIsValidAccount = true;
}
public sendMail()
{
session = new OutlookSession();
//eMail = new EmailMessage();
bool bFound = false;
foreach (Account acc in session.EmailAccounts)
{
System.Diagnostics.Debug.WriteLine(acc.Name);
if (acc.Name == "Google Mail")
bFound = true;
}
if (bFound)
account = session.EmailAccounts["Google Mail"];
else
{
if(this.createAccountGoogle())
account = session.EmailAccounts["Google Mail"];
}
if (account != null)
_bIsValidAccount = true;
}
/// <summary>
/// sync eMail using send and recv in foreground
/// </summary>
public void syncNow()
{
if (this.account != null)
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
}
/// <summary>
/// sync eMail in outlook
/// </summary>
/// <param name="pHandle">handle to forground window</param>
public void syncNow(IntPtr pHandle)
{
if (this.account != null)
{
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
SetForegroundWindow(pHandle);
}
}
public bool send(string sImagePath)
{
if (account == null)
return false;
try
{
eMail = new EmailMessage();
rcp = new Recipient(_to);
eMail.To.Add(rcp);
eMail.Subject = "Visitenkarten LogiMAT";
eMail.BodyText = "LogiMat " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\r\nsent from eMDI2Mail";
attachement = new Attachment(sImagePath);
eMail.Attachments.Add(attachement);
eMail.Send(account);
//account.Send(eMail);
if (this._syncImmediately)
{
if (this.account != null)
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
}
return true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Exception in send(): " + ex.Message);
}
return false;
}
public void Dispose()
{
if (account != null)
account.Dispose();
if (session != null)
session.Dispose();
}
public bool createAccountHotmail()
{
XMLConfig.Settings sett = new XMLConfig.Settings();
return XMLConfig.DMProcessConfig.ProcessXML(sett.appPath + "hotmail.xml");
}
public bool createAccountGoogle(){
XMLConfig.Settings sett= new XMLConfig.Settings();
return XMLConfig.DMProcessConfig.ProcessXML(sett.appPath + "gmail.xml");
/*
bool bRet = false;
string strTemp = "";
strTemp += "<wap-provisioningdoc>\r\n";
strTemp += " <characteristic type=\"EMAIL2\" recursive=\"true\">\r\n";
strTemp += " <characteristic type=\"{D45D5BE0-B96C-87A5-60B8-A59B69C733E4}\">\r\n";
strTemp += " <parm name=\"SERVICENAME\" value=\"Google Mail\" />\r\n";
strTemp += " <parm name=\"SERVICETYPE\" value=\"IMAP4\" />\r\n";
strTemp += " <parm name=\"INSERVER\" value=\"imap.googlemail.com\" />\r\n";
strTemp += " <parm name=\"AUTHNAME\" value=\"YourName@googlemail.com\" />\r\n";
strTemp += " <parm name=\"DOMAIN\" value=\"\" />\r\n";
strTemp += " <parm name=\"OUTSERVER\" value=\"smtp.googlemail.com\" />\r\n";
strTemp += " <parm name=\"REPLYADDR\" value=\"YourName@googlemail.com\" />\r\n";
strTemp += " <parm name=\"SMTPALTAUTHNAME\" value=\"YourName@googlemail.com\" />\r\n";
strTemp += " <parm name=\"SMTPALTDOMAIN\" value=\"\" />\r\n";
strTemp += " <parm name=\"NAME\" value=\"YourName 2011\" />\r\n";
strTemp += " <parm name=\"LINGER\" value=\"120\" />\r\n";
strTemp += " <parm name=\"RETRIEVE\" value=\"2048\" />\r\n";
strTemp += " <parm name=\"KEEPMAX\" value=\"0\" />\r\n";
strTemp += " <parm name=\"DWNDAY\" value=\"3\" />\r\n";
strTemp += " <parm name=\"FORMAT\" value=\"2\" />\r\n";
strTemp += " <parm name=\"AUTHREQUIRED\" value=\"1\" />\r\n";
strTemp += " <parm name=\"AUTHSECRET\" value=\"YourPassword\"/>\r\n";
strTemp += " </characteristic>\r\n";
strTemp += " </characteristic>\r\n";
strTemp += "</wap-provisioningdoc>";
return bRet;
*/
}
}
}
如您所见,该类还能够通过给定的 XML WAP 配置文件创建电子邮件帐户。
问候
约瑟夫
顺便说一句:该应用程序旨在使用 Intermec eMDI 技术在展会上制作一张特殊的名片照片。然后这些应该直接发送给秘书以创建这些线索。
OK,为了更简单明了:1. 为了能够使用 POutlook,您需要引用 poutlook session 。2. 为了能够通过代码发送电子邮件,您需要指定poutlook 必须使用的邮件帐户。3. 然后创建一个电子邮件对象并填写字段4.最后使用email对象的send方法与已有的account对象
更详细
创建 session 对象
OutlookSession session = new OutlookSession();
指定用于发送电子邮件的帐户。字符串必须与您定义的完全匹配PocketOutlook 电子邮件帐户名称。如果你用一个数字作为引用,你不能确定,哪个选择帐户。
EmailAccount account = session.EmailAccounts[sMailAccount];
检查返回的帐户。它是空的吗?现在创建一个新的 EMailMessage(与 TextMessage(SMS) 对比)
EmailMessage eMail = new EmailMessage();
然后填写EmailMessage对象的字段
Recipient rcp = new Recipient(_to);
eMail.To.Add(rcp);
eMail.Subject = "Visitenkarten";
eMail.BodyText = "Enter some eMail text to send";
最后发送邮件:
eMail.Send(account);
由于 poutlook 通常会定期在后台发送电子邮件,您可能希望让poutlook 立即发送邮件。如果是这样,您可以使用该代码:
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(account);
这将使poulook立即同步指定帐户的电子邮件,同时也带来了前景窗口到前景。
这是否简单明了?
关于c# - 在 Windows 中的 Windows 移动应用程序中发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13048272/
只是想知道 Jquery Mobile 是否足够稳定以用于实时生产企业移动应用程序。 有很多 HTML5 框架,因为我们的团队使用 JQuery 已经有一段时间了,我们更愿意使用 Jquery 移动框
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 3 年前。 Improve t
所以我尝试在 JavaScript 中对元素进行拖放。我使用的视频教程在这里; https://www.youtube.com/watch?v=KTlZ4Hs5h80 。我已经按照它的说明进行了编码,
无法在移动 iOS(safari 和 chrome)上自动播放以前缓存的 mp3 音频 我正在 Angular 8 中开发一个应用程序,在该应用程序的一部分中,我试图在对象数组中缓存几个传入的音频 m
Git 基于内容而不是文件,所以我目前理解以下行为,但我想知道是否有特殊选项或 hack 来检测此类事情: git init mkdir -p foo/bar echo "test" foo/a.tx
我正在寻找语义 ui 正确的类来隐藏例如移动 View 中的 DIV。在 Bootstrap 中,我们有“visible-xs”和“hidden-xs”。 但是在语义ui上我只找到了“仅移动网格” 最
我正在使用 ubuntu 和 想要移动或复制大文件。 但是当我与其他人一起使用服务器时,我不想拥有所有内存并使其他进程几乎停止。 那么有没有办法在内存使用受限的情况下移动或复制文件? 最佳答案 如果你
这些指令有什么区别?以 ARM9 处理器为例,它不应该是: ASM: mov r0, 0 C: r0 = 0; ASM: ld r0, 0 C: r0 = 0; ? 我不知道为什么要使用一个或另一个:
我有一个文件夹,其中包含一些随机命名的文件,其中包含我需要的数据。 为了使用数据,我必须将文件移动到另一个文件夹并将文件命名为“file1.xml” 每次移动和重命名文件时,它都会替换目标文件夹中以前
我经常在 IB/Storyboard 中堆叠对象,几乎不可能拖动其他对象后面的对象而不移动前面的对象。无论如何我可以移动已经选择但位于其他对象后面的对象吗?当我尝试移动它时,它总是选择顶部的对象,还是
几个月前,我看到 Safari 7 允许推送通知,它似乎是一个非常有用的工具,除了我看到的每个示例都专注于桌面浏览,而不是移动设备。 Safari 推送通知是否可以在移动设备上运行,如果没有,是否有计
我有一个简单的 View 模型,其中包含修改后的 ObservableCollection使用 SynchronizationContext.Current.Send在 UI 线程上执行对集合的更改。
关于cassandra创建的数据文件和系统文件的位置,我需要移动在“cassandra.yaml”配置文件中设置的“commitlog_directory”、“data_file_directorie
我有这个代码 $(function() { var message = 'Dont forget us'; var original; var txt1 = ' - '; $(wind
我的客户报告说他的网站有一个奇怪的问题。该网站的 URL 是 your-montenegro.me 在 基于 Android 的浏览器 上加载时,页面底部会出现一个奇怪的空白区域。以下是屏幕截图: 华
我有这个 HTML 标记: Express 300 bsf Sign Up 我需要将元素从 DOM 上的一个
我有一个可重新排序的 TableView (UITableView 实例)。尽管我已经实现了 UITableViewDataSource 方法: tableView:moveRowAtIndexPat
我的客户报告说他的网站有一个奇怪的问题。该网站的 URL 是 your-montenegro.me 在 基于 Android 的浏览器 上加载时,页面底部会出现一个奇怪的空白区域。以下是屏幕截图: 华
我需要在拖放或复制/剪切和粘贴(复制与移动)期间获取操作类型。它是一个 Swing 应用程序,并且实现了 TransferHandle。我在操作结束时需要此信息,在 importData 方法中。 对
我编写了一个具有 add 和 get 方法的 SortedIntList 类。 我调用以下四个方法: SortedIntList mySortedIntList = new SortedIntList
我是一名优秀的程序员,十分优秀!