Jose Vu
Jose Vu

Reputation: 696

Gmail API .NET: How to request messages from one sender

Currently, my boss wants me to write a software to get email from gmail and text it to a mobile number. However, the email needs to be from one sender only, my current solution is to use gmail-api get all the messages in the INBOX then filter using the payload.header.Value I notice that when create the UsersResource.MessagesResource.ListRequest I can add some filters such as

let emailListReq = service.Users.Messages.List( userId = "me")
emailListReq.LabelIds <- Google.Apis.Util.Repeatable<string>(["INBOX";"UNREAD"])    
emailListReq.IncludeSpamTrash <- Nullable<bool>(false)

I wonder is there a way to add the sender in to the filter such as

emailListReq.Sender <- "[email protected]"

Thanks

Upvotes: 2

Views: 528

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117271

You can use search for messages to find the messages you are looking for the string you sent to q is the same as the string you would use when searching in the gmail application so you can use that to test your search.

let emailListReq = service.Users.Messages.List( userId = "me")
emailListReq.Q <- "from:([email protected])"

Note I am not a F# developer i am guessing at the code.

Upvotes: 2

Related Questions