In gmail you have to verify the email address before you can forward emails to it. The verification code comes in the body of the email not as an attachment so expensify rejects it 🙁
You can use a Script in Gmail to forward emails
// Forwards all emails in the inbox from `from_email` to Expensify, and archive them.
//
// To use:
// Add this function to a Google Apps Scripts project, and add a trigger (in Resources -> Current Project Triggers)
// to call it on a given interval.
// Make sure to specify the senders you'd like to forward!
function toExpensifyBySender() {
var fromEmails = [
"[email protected]"
];
fromEmails.forEach(function(email) {
var threads = GmailApp.search('from:' + email + ' in:inbox');
threads.forEach(function(thread) {
thread.getMessages().forEach(function(message) {
message.forward('[email protected]');
});
thread.moveToArchive();
});
});
}
function toExpensifyBySender() {
var fromEmails = [
"[email protected]"
];
// Subject terms with wildcards
var subjectTerms = [
"receipt for your payment to aliexp*"
];
// Convert to regex patterns with simpler approach
var termPatterns = subjectTerms.map(term => {
// Replace * with .* and ensure proper escaping
const patternStr = term.replace('*', '.*');
const regex = new RegExp(patternStr, 'i');
Logger.log('Created pattern: ' + regex);
return regex;
});
try {
fromEmails.forEach(function(email) {
var searchQuery = 'from:' + email + ' in:inbox';
Logger.log('Search query: ' + searchQuery);
var threads = GmailApp.search(searchQuery);
Logger.log('Found ' + threads.length + ' threads');
if (threads.length === 0) {
Logger.log('No threads found for ' + email);
return;
}
threads.forEach(function(thread, threadIndex) {
Logger.log('Processing thread ' + threadIndex);
var messages = thread.getMessages();
var hasMatchingMessage = false;
messages.forEach(function(message, msgIndex) {
var subject = message.getSubject().toLowerCase();
Logger.log('Thread ' + threadIndex + ', Message ' + msgIndex + ' subject: "' + subject + '"');
// Test each pattern explicitly
var matchedPattern = termPatterns.find(pattern => {
const matches = pattern.test(subject);
Logger.log('Testing pattern ' + pattern + ' against "' + subject + '": ' + matches);
return matches;
});
if (matchedPattern) {
if (!message.isInTrash() && !message.isDraft()) {
Logger.log('Matched pattern: ' + matchedPattern + ' - Forwarding message');
message.forward('[email protected]', {
name: 'Expense Bot',
noReply: true
});
hasMatchingMessage = true;
} else {
Logger.log('Message skipped (in trash or draft)');
}
} else {
Logger.log('No pattern matched for this subject');
}
});
if (hasMatchingMessage) {
Logger.log('Archiving thread ' + threadIndex);
thread.moveToArchive();
} else {
Logger.log('Thread ' + threadIndex + ' had no matching messages');
}
});
});
} catch (error) {
Logger.log('Error occurred: ' + error.toString());
}
}

