分享

軟體開發

電話
魏〇偉
案件已認證
有提供電話
地區南投縣 埔里鎮
金額顧客預算:沒有預算概念
RD 工作 web 接案 Programmer 工作

您需要開發的項目是?

後台管理系統

您希望使用哪種程式語言?

Python

您需要其他服務嗎?

都不需要

您的項目目前狀態為?

有想法與介面流程設計

請說明軟體內容、設計目的、期望目標或其他所需要的設計細節,讓專家更了解詳情

python create Jira ticket: 用家以email 寫內容, 當program 看到有email進來,就create Jira ticket。我會provide:Python 初稿、Email範例。請找幫手接續寫python program。 本身這script已能開ticket,但還要做到: 1. 能辨別subject [I4](這是英文小寫「I」) 2. ⁠能辨別email content裡的fields 和 內容就要再改量

您可以上傳設計圖或參考介面,讓專家更了解您的需求

軟體開發案件圖片

您的預算大約為何?

沒有預算概念

您希望如何與專家合作? (可複選)

透過電話或網路進行

還有什麼需要注意的地方嗎?

有, import imaplib from email.header import decode_header from email.parser import BytesParser from jira import JIRA import requests import html2text requests.packages.urllib3.disable_warnings() # IMAP settings IMAP_SERVER = '<exchange.server>' USERNAME = '<AD>' PASSWORD = '<Password>' # Jira settings JIRA_URL = '<https://tool-dev.home/jira>' JIRA_USERNAME = '<AD>' JIRA_PASSWORD = '<Password>' JIRA_PROJECT_KEY = 'I4' options = { 'server': JIRA_URL, 'verify': False # Disable certificate verification } # Mailbox paths INBOX_PATH = 'inbox/test/ingest' COMPLETED_PATH = 'inbox/test/completed' # Connect to IMAP server print('Connecting to IMAP server...') imap_server = imaplib.IMAP4_SSL(IMAP_SERVER) imap_server.login(USERNAME, PASSWORD) print('Connected to IMAP server.') # Select the mailbox to monitor print(f'Selecting mailbox: {INBOX_PATH}') imap_server.select(INBOX_PATH) print(f'Selected mailbox: {INBOX_PATH}') # Connect to Jira using the API URL print('Connecting to Jira...') jira = JIRA(options, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD)) print('Connected to Jira.') def create_jira_ticket(summary, description): issue_dict = { 'project': {'key': JIRA_PROJECT_KEY}, # Replace with the actual project key 'summary': summary, 'description': description, 'issuetype': {'name': 'Task'} } new_issue = jira.create_issue(fields=issue_dict) print(f'Jira ticket created: {new_issue.key}') # Function to convert HTML to plaintext def html_to_plaintext(html_content): h = html2text.HTML2Text() h.ignore_links = True h.ignore_images = True h.ignore_emphasis = True return h.handle(html_content) # Search for all emails in the mailbox print('Searching for emails...') status, messages = imap_server.search(None, 'ALL') if status == 'OK': print(f'Found {len(messages[0].split())} email(s).') for num in messages[0].split(): _, msg_data = imap_server.fetch(num, '(RFC822)') for response_part in msg_data: if isinstance(response_part, tuple): msg = BytesParser().parsebytes(response_part[1]) # Parse email headers headers = decode_header(msg['Subject']) subject = None for header in headers: decoded_header = header[0] if header[1]: charset = header[1] # Decode the subject using the specified charset decoded_header = decoded_header.decode(charset) subject = decoded_header # Parse email body if needed body = None for part in msg.walk(): content_type = part.get_content_type() if content_type == "text/plain": body = part.get_payload(decode=True).decode('utf-8') break # Exit the loop after finding the plain text part elif content_type == "text/html": html_body = part.get_payload(decode=True).decode('utf-8') body = html_to_plaintext(html_body) break # Exit the loop after converting HTML to plaintext # Create Jira ticket print('Processing email...') create_jira_ticket(subject, str(body)) # Move the email to the completed mailbox print(f'Moving email to {COMPLETED_PATH}...') imap_server.copy(num, COMPLETED_PATH) imap_server.store(num, '+FLAGS', '\\Deleted') print('Email moved to the completed mailbox.') # Permanently remove deleted emails and logout from IMAP server print('Cleaning up...') imap_server.expunge() imap_server.logout() print('Cleanup completed.') print('Done.')

您需要服務的地區為何?

南投縣,埔里鎮
您可能也感興趣的案件:
南投縣 南投市
PLC設計
劉〇瑋
南投縣 南投市
PLC設計
劉〇瑋
彰化縣 永靖鄉
網站架設
陳〇茹