WordPress Error Saving Media Attachment

Custom WordPress Development for Non-Coders

Posts and pages aren’t enough for every site. When you need more, Toolset is the answer. Toolset lets you build your own listing sites, directories, membership sites and shops.

Avoid lengthy development and the limitations of complex themes. Build advanced sites yourself quickly and easily with Toolset.

Works with any theme and page builder

Build Rich Presentation Sites

Custom types, fields and taxonomy makes it easier to manage content and easier to display it. With Toolset, you can add custom types to WordPress in a few clicks. You’ll be able to design templates and build queries without any programming.

Create Custom Interactive Sites

Toolset allows you to build interactive sites, where visitors and members can edit content with front-end forms. With Toolset Forms and Access, you can create custom directory and classified sites and your own membership sites.

Save Outlook Mail Attachment to Local Folder

Outlook VBA Save Attachments

Use this code to Automatically Save email Attachments to a Folder.

In this article, we will be getting Outlook VBA code to perform 2 tasks.

  1. Vba Code to save mail attachments from Outlook Folder (Inbox).
  2. Outlook macro to save attachments from Any Outlook Folder.

You received an interesting useful document as email attachment from your colleague or friend. You want to refer that attachment. But, it seems very hard to search them in each email in Outlook or by using the search option.

If you have Outlook macro to save attachments to a folder in your system, it would be easy to search. Here is how we can do this.

Extract Outlook Email Attachment documents to a Folder using VBA

The VBA Macro code explained in this topic will be useful when a mail folder in Outlook has lot of mail attachments and you want to extract/save all attachments to a folder.

Would that be an easy task to manually open each mail, right click & save attachment to a folder? This is where this automation would save some time.

First of all to get to access to an Attachment in Microsoft Outlook Client, we should have a basic knowledge about the object model of Outlook and how to traverse through the below listed hierarchy.

  1. Name Space
  2. Mail Folder
  3. Mail Item
  4. Attachment

This is the order in which we will extract Attachments from each mail item and store them in a local folder.

VBA to Extract Outlook Mail Attachment

Name Space is used to get a reference to the Outlook Application using the command GetNameSpace (“MAPI”). Here MAPI refers to the mail protocol that is used in Outlook (Messaging API). Other Protocols commonly in use are POP and IMAP.

Once we get the instance to the Outlook Application, we drill down to desired folder (Inbox, Sent Items, Drat, Sent etc), then to the each mail present in the selected folder and then to the mail attachment.

Let’s see how it is done with the code. (This code will work fine in Outlook 2007 or 2003)

  1. Create a Folder “Attach” in drive D:\.
  2. Open Outlook Application.
  3. Press Alt + F11 to view the VB editor.
  4. Copy paste the below code to the editor.
  5. Execute the code by pressing F5.

Custom user avatar in wordpress

By default, WordPress uses Gravatar for displaying user’s profile picture based on your email ID registered with Gravatar. WordPress has user profile page in dashboard which contains number of fields for entering user data, but it lacks image field for adding custom user avatar.

In this tutorial, we will dig into how to add custom user avatar in WordPress. So let’s begin !

As I always say that hooks in WordPress are the ones which creates magic, here also we will be using hooks to add media uploader button to user edit profile page.

Adding media uploader to user edit profile page is 3 step process.

Step 1: Add script to page.

In this step we will add necessary Javascript to admin pages. First we will call wp_enqueue_media which enqueues all scripts, styles, settings, and templates necessary to use all media JavaScript APIs.

Another script will be for opening media uploader on button click and to insert attachment id in DOM.

please copy following script into a file and name that file as uploader.js

Now, add noth scripts in admin as follows.

Please note that I saved uploader.js in js folder in my theme, so you have to apply correct path of according to location of uploader.js in your theme.

Step 2: Adding uploder button to edit profile page.

In above code, we are using show_user_profile, edit_user_profile and user_new_form hooks to add upload button, so that button will be visible to existing user’s profile page as well as when creating new users.

Input button is to open wordpress media uploader on click.
Input hidden field is to store attachment id of insersted or selected image from media uploader of wordpress.

Step 3: Save the attachment image id to usermeta table in wordpress.

Usermeta table in WordPress is to store extra information related to user, here we will store attachment id of image for the user. Using that attachment id we can fetch all the data of concerned image.

For saving attachment id we will use profile_update and user_register hooks which will be fired when any new user is created or existing user is updated.

That’s it and you have successfully added profile pic uploader button to profile page in dashboard of WordPress.

Please comment if you have some waves running in your mind. 😉

Leave a Reply

Your email address will not be published. Required fields are marked *