어쩌다보니 hwp파일에 있는 내용을 복사해서

이메일을 전송해야 했습니다.

내용은 아래의 표였는데 복사가 안 되었습니다.


소속직무성명전화번호이메일주소






검색해보니 Cloudcodes Insertable라는 크롬 익스텐션을 설치하는 방법이 많이 나옵니다.

그런데 막상 크롬 웹스토어에서 찾아보면 조회가 안 되었습니다.


괜히 한글로 검색했다고 후회하고 영어로 검색하니 깔끔한 방법이 나옵니다.

구글쉬트(googlesheet)에 내용을 작성하고 복사/붙여넣기 하면 끝이었습니다.

http://usingtechnologybetter.com/add-a-table-to-a-gmail-message/


자주 쓰지도 않을 익스텐션 설치할 필요도 없고 좋았습니다.


반응형

그냥 한글을 인코딩해서 gmail 전송하면 한글이 전부 깨져버리는 문제가 발생

구글링해서 찾아보면 python2.x 코드가 있음


그래서 python3.5에서 만들어서 시험한 코드를 이곳에 기록함


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def send_with_gmail(body):
    import smtplib
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText

    gmail_user = 'my_id'  # 실제 google 로그인할 때 쓰는 ID
    gmail_pw = 'my_pw'    # 실제 google 로그인할 때 쓰는 Password

    from_addr = 'sender@gmail.com'   # 보내는 사람 주소
    to_addr = 'iam.byungwoo@gmail.com'      # 받는 사람 주소

    msg=MIMEMultipart('alternative')
    msg['From'] = from_addr
    msg['To'] = to_addr
    msg['Subject'] = 'Send email with Gmail'     # 제목
    msg.attach(MIMEText(body, 'plain', 'utf-8')) # 내용 인코딩

    ########################
    # https://www.google.com/settings/security/lesssecureapps
    # Make sure less_secure_apps select 'use'
    ########################
    try:
        server = smtplib.SMTP("smtp.gmail.com", 587)
        server.ehlo()
        server.starttls()
        server.login(gmail_user, gmail_pw)
        server.sendmail(from_addr, to_addr, msg.as_string())
        server.quit()
        print('successfully sent the mail')
    except BaseException as e:
        print("failed to send mail", str(e))

if __name__ == '__main__':
    send_msg = '''
    multi
    L
    I
    N
    E
    '''
    send_with_gmail(send_msg)



반응형

+ Recent posts