python outlook 2010 error : (-2147467262, 'No such interface supported',None,None) - python-3.x

I am getting the error message below when I try the code:
(-2147467262, 'No such interface supported',None,None)(-2147467262, 'No such interface supported',None,None)
the code
import win32com.client as client
outlook=client.Dispatch('Outlook.Application')
namespace=outlook.GetNameSpace("MAPI")
Der=namespace.Folders['Drive']
Dinbox=Der.Folders['Inbox']
Dinbox_list=[x for x in Dinbox.items if x.Categories==""]
for message in Dinbox_list:
if "xyz" in message.CC or "xyz" in message.To :
message.Categories="xyz"

This error occurs trying to handle - let's say - unusual messages in your inbox or in any other folder. I got the same error when trying to read EntryID of a recalled message (which is visible in Outlook, but cannot be opened). So your code will have the same problems with the object. Solution: Put your last if-statement in a try-except-block.

Related

bioMart Package error: error in function useDataset

I am trying to use the biomaRt package to access the data from Ensembl, however I got error message when using the useDataset() function. My codes are shown below.
library(httr)
listMarts()
ensembl = useMart("ENSEMBL_MART_ENSEMBL")
listDatasets(ensemble)
ensembl = useDataset("hsapiens_gene_ensembl",mart = ensemble)
When I type useDataset function i got error message like this:
> ensembl = useDataset("hsapiens_gene_ensembl",mart = ensembl)
Ensembl site unresponsive, trying asia mirror
Error in textConnection(text, encoding = "UTF-8") :
invalid 'text' argument
and sometimes another different error message showed as:
> ensembl = useDataset("hsapiens_gene_ensembl",mart = ensembl)
Ensembl site unresponsive, trying asia mirror
Error in textConnection(bmResult) : invalid 'text' argument
it seems like that the mirror automatically change to asia OR useast OR uswest, but the error message still shows up over and over again, and i don't know what to do.
So if anyone could help me with this? I will be very grateful for any help or suggestion.
Kind regards Riley Qiu, Dongguan, China

Python 3 Imaplib - (Errors : EXPUNGE failed ,BAD [b'Command Argument Error. 11'] ) Unable to delete the mails from Microsoft service account

Trail 1 :
result, data = mail.uid("STORE", str(message_id), "+X-GM-LABELS", '"\\Trash"')
o/p :
BAD [b'Command Argument Error. 11']
Trail 2 :
result, data = mail.uid('STORE', str(message_id) , '+FLAGS', '(\\Deleted)')
print("Deleted the mail : " , result ,"-", details_log[4])
result, data = mail.uid('EXPUNGE', str(message_id))
print("result",result)
print("data",data)
o/p :
Deleted the mail : OK
result NO
data [b'EXPUNGE failed.']
Issue : After Expunge , I even tried to close and logout the connection , but still it doesnt get deleted.
I know this post is old, but for anyone who reads it later on:
When using imaplib's select function to choose a mailbox to view (in my case, the "Inbox" mailbox), I had the readonly argument set to True, to be safe, but this blocked me from deleting emails in Microsoft Outlook. I set it to False and was able to delete emails with the store and expunge methods:
conn.select("Inbox", readonly=False)
# modify search query as you see fit
typ, data = conn.search(None, "FROM", "scammer#whatever.com")
for email in data[0].split():
conn.store(email, "+FLAGS", "\\Deleted")
conn.expunge()
conn.close()
conn.logout()

Sending mail with Python's smtplib returns "501 5.1.3 Invalid address"

Consider this code extract:
import smtplib
from email.message import EmailMessage
body = "some content"
email = EmailMessage()
email.set_content(body, subtype='html')
to = "you#work.com"
email['From'] = "me#work.com"
email['To'] = to
email['Cc'] = ""
email['Bcc'] = ""
email['Subject'] = "Hello"
smtp_connection = smtplib.SMTP("smtp.work.com", 25)
status = smtp_connection.send_message(email)
print(str(status))
print(to)
When running the code, the mail actually arrives correctly at the destination, but the print statement returns this: {'': (501, b'5.1.3 Invalid address')}
I've seen other posts around on the internet with similar error message, where it's been a case of malformed recipient addresses causing the message not to be delivered, but in my case the emails actually do get delivered correctly. I've also made sure that the email address output'ed by the last print statement is actually correct.
Any input on how to debug this further will be appreciated.
I believe I found the answer. Looks like empty "CC" and "BCC" values causes the error. When I removed these I got rid of the error message.
If your Cc and Bcc is also empty, it is no need to attach it in email[]

Recursively getting body of email with Pyzmail module

I'm trying to create an app that needs to recursively check an email address for new emails and then do some other stuff; I'm having some problems with the getting the body of the emails, though. I'm using the pyzmail module alongside imapclient, and the Automate the Boring Stuff for guidance (with python 3.6). Here's my code:
mail = imapclient.IMAPClient('imap.gmail.com', ssl=True)
mail.login('email', 'password')
mail.select_folder('INBOX', readonly=False)
uid = mail.gmail_search('NC')
for i in uid:
message = mail.fetch(i, ['BODY[]'], 'FLAGS')
msg = pyzmail.PyzMessage.factory(message[i][b'BODY[]'])
msg.html_part.get_payload().decode(msg.text_part.charset)
But it's not working. I've basically tried different forms of this code but to no avail and there's really not that many examples that can help me along. I'm a bit of a python newbie. Can anybody help?
Thanks,
EDIT
I realized where I made a mistake and fixed a bit of the code:
server = imapclient.IMAPClient('imap.gmail.com', ssl=True)
server.login('p.imagery.serv#gmail.com', 'rabbitrun88ve')
server.select_folder('INBOX', readonly=True)
uids = server.gmail_search('NC')
for i in uids:
messages = server.fetch(i, ['BODY[]'])
msg = pyzmail.PyzMessage.factory(messages[b'BODY[]'])
The problem I'm having is with the last line, which I dont know how to fed using the variables that is created with the iterator. It throws out this message:
ValueError: input must be a string a bytes, a file or a Message
I'm not sure if you still have this problem but for those who might have similar issues in future.
I noticed a little omission in the last line which might be the culprit.
msg = pyzmail.PyzMessage.factory(messages[b'BODY[]'])
You omitted the 'i' variable of the for loop
msg = pyzmail.PyzMessage.factory(messages[i][b'BODY[]'])
I'd like to do next to get body text of searched messages:
server = imapclient.IMAPClient('imap.gmail.com', ssl=True)
server.login('p.imagery.serv#gmail.com', 'rabbitrun88ve')
server.select_folder('INBOX', readonly=True)
uids = server.gmail_search('NC')
rawmessage = server.fetch(uids, ['BODY[]'])
for i in rawmessage:
msg = pyzmail.PyzMessage.factory(rawmessage[i][b'BODY[]'])
msg.html_part.get_payload().decode(msg.text_part.charset)
In this case, you get iteration over fetched emails with body text. I checked similar example but I used text_part.get_payload() instead html regarding features of my server.

Netsuite CSV import(An unexpected error has occurred)

Below is the sample code, i am using in CSV Import process.
var createJob = nlapiCreateCSVImport();
createJob.setMapping("CUSTIMPORTcust_pay");
createJob.setPrimaryFile("Data_string");
createJob.setOption("jobName", "Test imports");
var JobId = nlapiSubmitCSVImport(createJob);
nlapiSubmitCSVImport function is returning JobId without any error, but in job status page[UI] it showing status is failed and in Message field it showing "An unexpected error has occurred", CSV Response field also empty. when i try this by running the above code with same data again, some time it is successfully imported and some time it got failed, with showing message "An unexpected error has occurred"
Please see setPrimaryFile(file).
Where file is either:
The internal ID, as shown in the file cabinet, of the CSV file containing data to be imported, referenced by nlapiLoadFile. For example:
.setPrimaryFile(nlapiLoadFile(73))
Raw string of the data to be imported.
You are passing in a raw string of "Data_string".

Resources