@@ -103,7 +103,8 @@ export function setupGmailHandlers(ipcMain: IpcMain, store: Store<AppConfig>, ma
103103 scope : [
104104 'https://www.googleapis.com/auth/gmail.send' ,
105105 'https://www.googleapis.com/auth/gmail.readonly' ,
106- 'https://www.googleapis.com/auth/spreadsheets'
106+ 'https://www.googleapis.com/auth/spreadsheets' ,
107+ 'https://www.googleapis.com/auth/gmail.settings.basic'
107108 ] ,
108109 prompt : 'consent'
109110 } ) ;
@@ -208,14 +209,30 @@ export function setupGmailHandlers(ipcMain: IpcMain, store: Store<AppConfig>, ma
208209 refresh_token : config . google . refreshToken
209210 } ) ;
210211
212+ // Fetch user's signature
213+ let signature = '' ;
214+ try {
215+ const sendAsResponse = await gmail . users . settings . sendAs . list ( {
216+ auth : client ,
217+ userId : 'me'
218+ } ) ;
219+ const aliases = sendAsResponse . data . sendAs || [ ] ;
220+ const alias = aliases . find ( a => a . sendAsEmail === config . user . email ) || aliases . find ( a => a . isPrimary ) ;
221+ if ( alias && alias . signature ) {
222+ signature = `<br><br>${ alias . signature } ` ;
223+ }
224+ } catch ( sigError ) {
225+ console . warn ( 'Failed to fetch signature:' , sigError ) ;
226+ }
227+
211228 // Create email
212229 const message = [
213230 `From: ${ config . user . name } <${ config . user . email } >` ,
214231 `To: ${ emailData . to } ` ,
215232 `Subject: ${ emailData . subject } ` ,
216233 'Content-Type: text/html; charset=utf-8' ,
217234 '' ,
218- emailData . body
235+ emailData . body + signature
219236 ] . join ( '\n' ) ;
220237
221238 const encodedMessage = Buffer . from ( message )
0 commit comments