我有一个可爱的小Java客户端发送签名的电子邮件.我们有一台Exchange服务器,需要用户名/密码验证才能发送邮件.
当我连接到Exchange服务器时,我收到此错误:
avax.mail.AuthenticationFailedException: failed to connect
at javax.mail.Service.connect(Service.java:322)
at javax.mail.Service.connect(Service.java:172)
Run Code Online (Sandbox Code Playgroud)
当我连接到其他服务器(Unix服务器)时,我没有问题.
下面是完整的调试跟踪.我无法弄清楚.
DEBUG: JavaMail version 1.4.2
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SM}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], }
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "SERVER", port 25, isSSL false
220 SERVER ESMTP (deca81216f2ecf4fd6fedb030e3dcfd0)
DEBUG SMTP: connected to host …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试使用http://sudzc.com/中的一些生成代码. 这段代码并不完全适合我的Web服务,因此我尝试将类别添加到一些生成的类中,并使用原始类替换它们的实现来自"objc/runtime.h"的method_exchangeImplementations.(我可以直接修改生成的代码,但我想避免它).
这是我在MyAppAppDelegate中执行的代码 - applicationDidFinishLaunching方法
Class theClass = [CBMayaIPhoneUser class];
Method originalMethod = class_getClassMethod(theClass, @selector(initWithNode:));
Method categoryMethod = class_getClassMethod(theClass, @selector(initWithAllStringNode:));
method_exchangeImplementations(originalMethod, categoryMethod);
theClass = [Soap class];
originalMethod = class_getClassMethod(theClass, @selector(getNodeValue:withName:));
categoryMethod = class_getClassMethod(theClass, @selector(getHrefNodeValue:withName:));
method_exchangeImplementations(originalMethod, categoryMethod);
theClass = [SoapRequest class];
originalMethod = class_getClassMethod(theClass, @selector(send));
categoryMethod = class_getClassMethod(theClass, @selector(sendIgnoringCertificate));
method_exchangeImplementations(originalMethod, categoryMethod);
originalMethod = class_getClassMethod(theClass, @selector(connectionDidFinishLoading:));
categoryMethod = class_getClassMethod(theClass, @selector(connectionDidFinishLoadingAndSentBody:));
method_exchangeImplementations(originalMethod, categoryMethod);
Run Code Online (Sandbox Code Playgroud)
正如我的问题所述,几乎所有这些class_getClassMethod都返回nil ...我使用了调试器,所以我知道'theClass'是正确设置的.找到的唯一方法是Soap类,它们都是类级(+)方法.但是从网上的各种例子中我得出的结论是,它也适用于其他人......
以下是MyAppAppDelegate.m的包含:
#import "MyAppAppDelegate.h"
#import "RootViewController.h"
#import "MyGlobalVariables.h"
#import "MyWebServiceExample.h"
#import "Soap+Href.h"
#import "SoapRequest+Certificate.h"
#import "CBMayaIPhoneUser+AllString.h"
#import …Run Code Online (Sandbox Code Playgroud) implementation exchange-server objective-c-runtime ios-simulator
我想交换两个可以为空的十进制值,如下所示:
o2 = Interlocked.Exchange(ref o1, o2);
Run Code Online (Sandbox Code Playgroud)
类型'十进制?' 必须是引用类型才能在泛型类型或方法'System.Threading.Interlocked.Exchange(ref T,T)'中将其用作参数'T'.
有没有比这更好的想法:
decimal? temp = o1;
o1 = o2;
o2 = temp;
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我想从电子邮件中的附件中获取内容.我能够阅读电子邮件及其所有属性.附件是一个文本文件(.txt).我如何获取附件的实际文本内容?下面是我的代码的一部分,显示我如何获取每封电子邮件,然后获取其属性并将其存储在findResults列表中.像fileAttachment.Name这样的东西会给我附件的名称.fileAttachment.content.tostring()只显示system.Byte [].
FindItemsResults<Item> findResults = service.FindItems(fid1, new ItemView(int.MaxValue));
service.LoadPropertiesForItems(from Item item in findResults select item, PropertySet.FirstClassProperties);
foreach (Item item in findResults)
{
String body = "";
#region attachments
if (ReadAttachments == "1")
{
EmailMessage message = EmailMessage.Bind(service, item.Id, new PropertySet(BasePropertySet.IdOnly, ItemSchema.Attachments));
foreach (Attachment attachment in message.Attachments)
{
if (attachment is FileAttachment)
{
FileAttachment fileAttachment = attachment as FileAttachment;
// Load the file attachment into memory and print out its file name.
fileAttachment.Load();
String attachbody = fileAttachment.Content.ToString();
if (attachbody.Length > 8000) …Run Code Online (Sandbox Code Playgroud) 使用Exchange托管ApI,我需要获得创建日期更新或等于定义日期的所有约会.我怎么做?
有没有人有任何php-ews的经验?我想通过php-ews添加一个新的约会到Exchange 2007日历,但我不知道如何.php-ews的文档非常有限.有没有人以前做过这件事,并提供和示例?谢谢
我使用EWS托管API在我的c#项目和我们的Exchange 2010服务器之间进行通信.我使用此代码从现在起和三天前收到收件箱中的所有邮件.
var ews = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
ews.Credentials = new NetworkCredential(usr, psw, dmn);
ews.AutodiscoverUrl(url);
PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
itempropertyset.RequestedBodyType = BodyType.Text;
ItemView view = new ItemView(int.MaxValue);
FindItemsResults<Item> findResults;
view.PropertySet = itempropertyset;
do
{
findResults = ews.FindItems(WellKnownFolderName.Inbox, view);
foreach (Item item in findResults.Items)
{
if (item.DateTimeCreated < DateTime.Now.AddDays(-3)) continue;
item.Load(itempropertyset);
var message = EmailMessage.Bind(ews, item.Id,
new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Attachments));
string to = message.ToRecipients[0].Address.ToLower();
string body = item.Body;
}
view.Offset += findResults.TotalCount;
} while (findResults.MoreAvailable);
Run Code Online (Sandbox Code Playgroud)
现在问题.我想改进这一行, if (item.DateTimeCreated < DateTime.Now.AddDays(-3)) continue;因为当我使用它时,api从收件箱中获取所有消息,如果它比旧的那么三天就继续.我想在代码中先前指定此过滤器,因此api不必处理所有消息.
使用Exchange 2013 SP1和Exchange Web服务托管API 2.2尝试获取我存储在"公用文件夹"中的联系人文件夹中的联系人列表. 我想将ItemView的大小限制为我在此联系人文件夹中的联系人总数,但是当我尝试返回该属性(contactfolder.TotalCount)时,它总是返回0.如果我尝试使用联系人我邮箱下的文件夹返回0以外的值.我可以通过将ItemView的构造函数的值指定为特定数字或使用int.MaxValue来解决此问题,但我宁愿使用联系人列表中的项目总数.非常感谢任何帮助!这是相关代码:
private FindItemsResults<Microsoft.Exchange.WebServices.Data.Item> ExchangeContacts()
{
// Setup the exchange server connection.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.AutodiscoverUrl("someone@mydomain.com");
// Set the filter to choose the correct contact list
SearchFilter filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "My Public Contacts");
SearchFilter.SearchFilterCollection filterCollection = new SearchFilter.SearchFilterCollection();
filterCollection.Add(filter);
// Get the FolderId using the search filter.
Folder parent = Folder.Bind(service, WellKnownFolderName.PublicFoldersRoot);
FindFoldersResults results = parent.FindFolders(filter, new FolderView(1));
FolderId fid = results.Single().Id;
// Get the Contact folder based on the folderid.
ContactsFolder …Run Code Online (Sandbox Code Playgroud) exchange-server ×10
c# ×5
.net ×2
email ×2
php ×2
attachment ×1
decimal ×1
java ×1
javax.mail ×1
nullable ×1
smtp-auth ×1