ews-cpp  0.9
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ews::attachment Class Referencefinal

Represents a <FileAttachment> or an <ItemAttachment> More...

#include <ews.hpp>

Public Types

enum  type {
  type::item,
  type::file
}
 Describes whether an attachment contains a file or another item. More...
 

Public Member Functions

std::string content () const
 Returns the attachment's contents. More...
 
std::string content_id () const
 Returns the attachement's content ID. More...
 
size_t content_size () const
 Returns the attachment's size in bytes. More...
 
std::string content_type () const
 Returns the attachment's content type.
 
std::string get_mime_content () const
 Returns the attachment's mime content. More...
 
type get_type () const EWS_NOEXCEPT
 Returns either type::file or type::item.
 
attachment_id id () const
 Returns this attachment's attachment_id.
 
bool is_inline () const
 Returns true if the attachment is inlined.
 
std::string name () const
 Returns the attachment's name.
 
std::string to_xml () const
 Returns this attachment serialized to XML.
 
size_t write_content_to_file (const std::string &file_path) const
 Write contents to a file. More...
 

Static Public Member Functions

static attachment from_base64 (const std::string &content, std::string content_type, std::string name)
 Creates a new <FileAttachment> from a given base64 string. More...
 
static attachment from_file (const std::string &file_path, std::string content_type, std::string name)
 Creates a new <FileAttachment> from a given file. More...
 
static attachment from_item (const item &the_item, const std::string &name)
 Creates a new <ItemAttachment> from a given item. More...
 
static attachment from_xml_element (const rapidxml::xml_node<> &elem)
 Constructs an attachment from a given XML element elem.
 

Detailed Description

Represents a <FileAttachment> or an <ItemAttachment>

Member Enumeration Documentation

enum ews::attachment::type
strong

Describes whether an attachment contains a file or another item.

Enumerator
item 

An <ItemAttachment>

file 

A <FileAttachment>

Member Function Documentation

std::string ews::attachment::content ( ) const
inline

Returns the attachment's contents.

If this is a <FileAttachment>, returns the Base64-encoded contents of the file attachment. If this is an <ItemAttachment>, the empty string.

std::string ews::attachment::content_id ( ) const
inline

Returns the attachement's content ID.

If this is an inlined attachment, returns the content ID that is used to reference the attachment in the HTML code of the parent item. Otherwise returns an empty string.

size_t ews::attachment::content_size ( ) const
inline

Returns the attachment's size in bytes.

If this is a <FileAttachment>, returns the size in bytes of the file attachment; otherwise 0.

static attachment ews::attachment::from_base64 ( const std::string &  content,
std::string  content_type,
std::string  name 
)
inlinestatic

Creates a new <FileAttachment> from a given base64 string.

Returns a new <FileAttachment> that you can pass to ews::service::create_attachment in order to create the attachment on the server.

Parameters
contentBase64 content of a file
content_typeThe (RFC 2046) MIME content type of the attachment
nameA name for this attachment

On Windows you can use HKEY_CLASSES_ROOT/MIME/Database/Content Type registry hive to get the content type from a file extension. On a UNIX see magic(5) and file(1).

static attachment ews::attachment::from_file ( const std::string &  file_path,
std::string  content_type,
std::string  name 
)
inlinestatic

Creates a new <FileAttachment> from a given file.

Returns a new <FileAttachment> that you can pass to ews::service::create_attachment in order to create the attachment on the server.

Parameters
file_pathPath to an existing and readable file
content_typeThe (RFC 2046) MIME content type of the attachment
nameA name for this attachment

On Windows you can use HKEY_CLASSES_ROOT/MIME/Database/Content Type registry hive to get the content type from a file extension. On a UNIX see magic(5) and file(1).

attachment ews::attachment::from_item ( const item the_item,
const std::string &  name 
)
inlinestatic

Creates a new <ItemAttachment> from a given item.

It is not necessary for the item to already exist in the Exchange store. If it doesn't, it will be automatically created.

std::string ews::attachment::get_mime_content ( ) const
inline

Returns the attachment's mime content.

If this is a <ItemAttachment> and the mime content was requested, returns the Base64-encoded mime content of the attachment. If this is an <FileAttachment> or the mime content was not requested, returns an empty string.

size_t ews::attachment::write_content_to_file ( const std::string &  file_path) const
inline

Write contents to a file.

If this is a <FileAttachment>, writes content to file. Does nothing if this is an <ItemAttachment>. Returns the number of bytes written.


The documentation for this class was generated from the following file: