我一直在试图弄清楚如何以编程方式将文件添加到Xcode4项目中,看起来AppleScript将成为可行的方式,但是我遇到了"缺失值"错误.
这是我得到的代码:
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
add theFileRef to theProject
end tell
--tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
Run Code Online (Sandbox Code Playgroud)
我已经尝试了注释掉的行而不是add-command,但这也不起作用(我得到"缺失值").
'添加'错误是:
error "Xcode got an error: file reference id …Run Code Online (Sandbox Code Playgroud) 我最近一直在制作自己的邮件客户端,并添加了一个接收选项,我使用mimekit和mailkit作为插件,并且能够使用应该显示内容的阅读器下载我的大部分邮件(现在它显示主题,来自,来自, ,日期)
我下载主题的方式是,...是msg.envelope.subject,msg.envelope.to但我无法下载这样的主体:(当做msg.body,msg.textbody,msg.bodyparts ,. ..他们都导致了NOTHING,它应该是空的地方,我无法下载:(
谁能帮我?
我正在使用一个名为EAgetmail的库来检索指定电子邮件的正文,它运行良好,但我现在正在使用Mailkit.问题在于EAgetmail等同于message.body返回主体,因为用户在电子邮件客户端中看到它,但在mailkit中它返回了许多不同的数据.
这是相关代码:
using (var client = new ImapClient())
{
client.Connect(emailServer, 993, true);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(username, password);
var inbox = client.Inbox;
inbox.Open(FolderAccess.ReadOnly);
SearchQuery query;
if (checkBox.IsChecked == false)
{
query = SearchQuery.DeliveredBefore((DateTime)dateEnd).And(
SearchQuery.DeliveredAfter((DateTime)dateStart)).And(
SearchQuery.SubjectContains("Subject to find"));
}
else
{
query = SearchQuery.SubjectContains("Subject to find");
}
foreach (var uid in inbox.Search(query))
{
var message = inbox.GetMessage(uid);
formEmails.Add(message.TextBody);
messageDate.Add(message.Date.LocalDateTime);
}
client.Disconnect(true);
}
Run Code Online (Sandbox Code Playgroud)
我也尝试了message.Body.ToString()并在消息部分中搜索纯文本,但都没有工作.我的问题是如何使用Mailkit复制EAgetmail的.body属性的效果(以纯文本形式返回正文内容,如用户所见)?
我尝试MailKit通过 SMTP 通过交换服务器发送电子邮件,但当我尝试连接时出现以下错误:
MailKit.dll 中发生“System.Security.Authentication.AuthenticationException”类型的异常,但未在用户代码中处理
附加信息:根据验证程序,远程证书无效。
谷歌搜索会带来很多有关 Gmail 的内容或作为其他错误消息的一部分(例如 FTP 或 Web api 请求等)。我已经与 IT 人员交谈过,它不是自签名证书,我们不需要身份验证(事实上,我管理的 BugZilla 实例使用相同的设置进行设置并且工作正常)。我做错了什么或者如何获得更多详细信息以进一步排除故障?
using (var Client = new SmtpClient())
{
Client.Connect("mail.address.com", 587, false);
Client.AuthenticationMechanisms.Remove("XOAUTH2");
Client.Send(Message);
Client.Disconnect(true);
}
Run Code Online (Sandbox Code Playgroud)
mail.address.com domain编辑:我已经与 IT 部门核实,它与托管 IIS和交换的IIS 中使用的证书相同。我也将其安装为受信任的根,但仍然遇到相同的错误。
编辑2:如果我将代码更新为,Client.Connect("mail.address.com", 587, true);则会收到错误:
>System.Private.Networking.dll 中发生“System.IO.IOException”类型的异常,但未在用户代码中处理
附加信息:由于数据包格式意外,握手失败。
我正在构建一个 C# 函数来定期从本地电子邮件服务器 (hMailServer) 获取电子邮件消息并保存到数据库表中。
var uid_list = await inbox.SearchAsync(SearchQuery.SentAfter(lastDateTime));
Run Code Online (Sandbox Code Playgroud)
问题是它忽略了时间部分,只比较日期部分。问题:如何使用 Mailkit 搜索比时间戳值新的邮件?
错误:邮箱不可用。服务器响应为:访问被拒绝-无效的HELO名称(请参阅RFC2821 4.1.1.1)
说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。
异常详细信息:System.Net.Mail.SmtpException:邮箱不可用。服务器响应为:访问被拒绝-无效的HELO名称(请参阅RFC2821 4.1.1.1)
源错误行61:
Line 59:
Line 60: SmtpClient smtp = new SmtpClient(SMTPServer, SMTPPort);
Line 61: smtp.Credentials = new NetworkCredential(SMTPUserId, SMTPPassword);
Line 62: smtp.Send(mail);
Line 63: }
Run Code Online (Sandbox Code Playgroud)
源文件:\ Websites \ Client \ Reports \ ContactUs.aspx.cs行:61
================================================== =======================
我的源代码:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string name = txtFirstName.Text + " " + txtLastName.Text;
string clientID = Session["CustomerID"].ToString();
string message = txtMessage.Text;
string email = txtEmail.Text;
string company = txtCompany.Text;
string phone = txtPhone.Text;
SMTPMailHelper.SendMail(email, …Run Code Online (Sandbox Code Playgroud) 我在网上查看了其他示例,但我无法弄清楚如何从MimeMessage对象下载和存储所有附件.我确实调查了WriteTo(),但我无法让它工作.还想知道附件是否会根据原始文件名保存,并在电子邮件中输入.这是我到目前为止:
using (var client = new ImapClient())
{
client.Connect(Constant.GoogleImapHost, Constant.ImapPort, SecureSocketOptions.SslOnConnect);
client.AuthenticationMechanisms.Remove(Constant.GoogleOAuth);
client.Authenticate(Constant.GoogleUserName, Constant.GenericPassword);
if (client.IsConnected == true)
{
FolderAccess inboxAccess = client.Inbox.Open(FolderAccess.ReadWrite);
IMailFolder inboxFolder = client.GetFolder(Constant.InboxFolder);
IList<UniqueId> uids = client.Inbox.Search(SearchQuery.All);
if (inboxFolder != null & inboxFolder.Unread > 0)
{
foreach (UniqueId msgId in uids)
{
MimeMessage message = inboxFolder.GetMessage(msgId);
foreach (MimeEntity attachment in message.Attachments)
{
//need to save all the attachments locally
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用此处找到的 IMAP Idle 示例代码
该示例需要 Console.ReadKey 来取消 CancellationTokenSource,但建议只要该事件有权访问 CancellationTokenSource,就可以在新邮件到达时在 CountChanged 事件中取消它。
如何访问 CountChanged 事件中的 CancellationTokenSource?
这是上面链接中的代码片段......
// Keep track of changes to the number of messages in the folder (this is how we'll tell if new messages have arrived).
client.Inbox.CountChanged += (sender, e) => {
// Note: the CountChanged event will fire when new messages arrive in the folder and/or when messages are expunged.
var folder = (ImapFolder)sender;
Console.WriteLine("The number of messages in {0} has changed.", folder);
// Note: …Run Code Online (Sandbox Code Playgroud) 可以使用OpenPop.dll.
Pop3Client objPOP3Client = new Pop3Client();
int intTotalEmail = 0;
DataTable dtEmail = new DataTable();
object[] objMessageParts;
try
{
dtEmail = GetAllEmailStructure();
if (objPOP3Client.Connected)
objPOP3Client.Disconnect();
objPOP3Client.Connect(strHostName, intPort, bulUseSSL);
try
{
objPOP3Client.Authenticate(strUserName, new Common()._Decode(strPassword));
intTotalEmail = objPOP3Client.GetMessageCount();
AddMapping();
for (int i = 1; i <= intTotalEmail; i++)
{
objMessageParts = GetMessageContent(i, ref objPOP3Client, dtExistMailList);
if (objMessageParts != null && objMessageParts[0].ToString() == "0")
{
AddToDtEmail(objMessageParts, i, dtEmail, dtUserList, dtTicketIDList, dtBlacklistEmails, dtBlacklistSubject, dtBlacklistDomains);
}
}
}
catch (Exception ex)
{
}
}
catch …Run Code Online (Sandbox Code Playgroud)