/// <summary>
        /// Modifies the labels applied to the thread. This applies to all messages in the thread.
        /// Documentation https://developers.google.com/gmail/v1/reference/threads/modify
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="id">The ID of the thread to modify.</param>
        /// <param name="body">A valid gmail v1 body.</param>
        /// <returns>ThreadResponse</returns>
        public static Thread Modify(gmailService service, string userId, string id, ModifyThreadRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Threads.Modify(body, userId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Threads.Modify failed.", ex);
            }
        }
        /// <summary>
        /// Immediately and permanently deletes the specified thread. This operation cannot be undone. Prefer threads.trash instead.
        /// Documentation https://developers.google.com/gmail/v1/reference/threads/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="id">ID of the Thread to delete.</param>
        public static void Delete(gmailService service, string userId, string id)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Threads.Delete(userId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Threads.Delete failed.", ex);
            }
        }
        /// <summary>
        /// Gets the specified message attachment.
        /// Documentation https://developers.google.com/gmail/v1/reference/attachments/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="messageId">The ID of the message containing the attachment.</param>
        /// <param name="id">The ID of the attachment.</param>
        /// <returns>MessagePartBodyResponse</returns>
        public static MessagePartBody Get(gmailService service, string userId, string messageId, string id)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (messageId == null)
                {
                    throw new ArgumentNullException(messageId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Attachments.Get(userId, messageId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Attachments.Get failed.", ex);
            }
        }
        /// <summary>
        /// Lists the threads in the user's mailbox.
        /// Documentation https://developers.google.com/gmail/v1/reference/threads/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ListThreadsResponseResponse</returns>
        public static ListThreadsResponse List(gmailService service, string userId, ThreadsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Building the initial request.
                var request = service.Threads.List(userId);

                // Applying optional parameters to the request.
                request = (ThreadsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Threads.List failed.", ex);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sends a verification email to the specified send-as alias address. The verification status must be pending.
        /// Documentation https://developers.google.com/gmail/v1/reference/sendAs/verify
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">User's email address. The special value "me" can be used to indicate the authenticated user.</param>
        /// <param name="sendAsEmail">The send-as alias to be verified.</param>
        public static void Verify(gmailService service, string userId, string sendAsEmail)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (sendAsEmail == null)
                {
                    throw new ArgumentNullException(sendAsEmail);
                }

                // Make the request.
                return(service.SendAs.Verify(userId, sendAsEmail).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request SendAs.Verify failed.", ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias.
        /// Documentation https://developers.google.com/gmail/v1/reference/sendAs/create
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">User's email address. The special value "me" can be used to indicate the authenticated user.</param>
        /// <param name="body">A valid gmail v1 body.</param>
        /// <returns>SendAsResponse</returns>
        public static SendAs Create(gmailService service, string userId, SendAs body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.SendAs.Create(body, userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request SendAs.Create failed.", ex);
            }
        }
        /// <summary>
        /// Gets a filter.
        /// Documentation https://developers.google.com/gmail/v1/reference/filters/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">User's email address. The special value "me" can be used to indicate the authenticated user.</param>
        /// <param name="id">The ID of the filter to be fetched.</param>
        /// <returns>FilterResponse</returns>
        public static Filter Get(gmailService service, string userId, string id)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Filters.Get(userId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Filters.Get failed.", ex);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Replaces a draft's content.
        /// Documentation https://developers.google.com/gmail/v1/reference/drafts/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="id">The ID of the draft to update.</param>
        /// <param name="body">A valid gmail v1 body.</param>
        /// <returns>DraftResponse</returns>
        public static Draft Update(gmailService service, string userId, string id, Draft body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Drafts.Update(body, userId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Drafts.Update failed.", ex);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the specified draft.
        /// Documentation https://developers.google.com/gmail/v1/reference/drafts/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">The user's email address. The special value me can be used to indicate the authenticated user.</param>
        /// <param name="id">The ID of the draft to retrieve.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>DraftResponse</returns>
        public static Draft Get(gmailService service, string userId, string id, DraftsGetOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Building the initial request.
                var request = service.Drafts.Get(userId, id);

                // Applying optional parameters to the request.
                request = (DraftsResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Drafts.Get failed.", ex);
            }
        }
        /// <summary>
        /// Deletes the specified forwarding address and revokes any verification that may have been required.
        /// Documentation https://developers.google.com/gmail/v1/reference/forwardingAddresses/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">User's email address. The special value "me" can be used to indicate the authenticated user.</param>
        /// <param name="forwardingEmail">The forwarding address to be deleted.</param>
        public static void Delete(gmailService service, string userId, string forwardingEmail)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }
                if (forwardingEmail == null)
                {
                    throw new ArgumentNullException(forwardingEmail);
                }

                // Make the request.
                return(service.ForwardingAddresses.Delete(userId, forwardingEmail).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request ForwardingAddresses.Delete failed.", ex);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases.
        /// Documentation https://developers.google.com/gmail/v1/reference/sendAs/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated gmail service.</param>
        /// <param name="userId">User's email address. The special value "me" can be used to indicate the authenticated user.</param>
        /// <returns>ListSendAsResponseResponse</returns>
        public static ListSendAsResponse List(gmailService service, string userId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.SendAs.List(userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request SendAs.List failed.", ex);
            }
        }