Representing de Rham cohomology by smooth maps It is well-known that in the homotopy category of, say, CW-complexes the singular cohomology functor is represented by the Eilenberg-Maclane spaces: $H^n(M,\mathbb{Z})=[M,K(\mathbb{Z},n)]$. My question is, if $M$ is a smooth Riemannian manifold, can one choose the representing map to be smooth (in any sense)? 
For example, every de Rham cohomology class contains a unique harmonic form and for $n=1$ we have the "Albanese" map from $M$ into a circle, given by the integration of this form. 
Can we do something similar for $n>1$? 
 A: An answer to this question is implicit in Pawel Gajer's nice paper, "Geometry of Deligne Cohomology."  Gajer describes a formalism by which one can view $B^{n-1}S^1$ or $B^{n-1}\mathbb{C}^*$ as "differentiable spaces," and in which classes in $H^n(X, \mathbb{Z})$ classify equivalence classes of "smooth" principal $B^{n-2}\mathbb{C}^*$bundles.  While Gajer doesn't explicitly write this out, one can see that replacing $X$ with an appropriate hypercover $X_\bullet$, such bundles are classified by "smooth" maps $X_\bullet\to B^{n-1}\mathbb{C}^*$.
And for an appropriate model structure on the category of simplicial presheaves on the category of manifolds, $H^n(X, \mathbb{Z})$ will precisely be homotopy classes of "smooth" maps $X\to B^{n-1}\mathbb{C}^*$.  One can extract this from work of Jardine, Goerss, Dugger, etc., or if you contact me by email, I can send you a draft on related things.  
Everything I've written above is essentially tautological, but it's fun to work through it carefully.

Added later, since David Speyer's answer has inspired me to write something explicit:  Let $X$ be a compact manifold, and $\omega\in H^2(X, \mathbb{Z})$ a class corresponding to a complex line bundle $\mathcal{L}$.  Choose a cover $\{U_i\}_{i=1}^{n+1}$ of $X$ so that $\mathcal{L}$ is trivial on each $U_i$.  Then I claim there is a smooth map $\phi: X\to \mathbb{CP}^n$ so that after composing with the usual inclusion $\mathbb{CP}^n\to \mathbb{CP}^\infty$, $\omega$ is pulled back from the universal class on $\mathbb{CP}^\infty$.
Indeed, consider another open cover $\{V_i\}_{i=1}^{n+1}$ of $X$ so that $\overline{V_i}\subset U_i$, and choose smooth sections $\psi_i$ to $\mathcal{L}$ which don't vanish on $V_i$ and which are zero outside of $U_i$ (which we may do as $\mathcal{L}$ is trivial on $U_i$).  Let $V$ be the span of the $\psi_i$ in $\Gamma(X, \mathcal{L})$.  Then there is a natural map $\text{ev}: V\times X\to L$ over $X$ given by evaluation of sections; this induces the desired smooth map $\phi: X\to \mathbb{CP}^n$ by sending a point $x\in X$ to the kernel of the fiber of $\text{ev}$ over $x$.  I will leave it to you to check that $\phi$ satisfies the desired property (hint: $\mathcal{L}=\phi^*(\mathcal{O}(1))$).
A: This is a partial answer to what I understand from the question: "...for n=1 we have the "Albanese" map from M into a circle, given by the integration of this form. Can we do something similar for n>1?".
The problem with the classical approaches is that, when you can represent a closed differential form it's only when the form is integral (in particular above, in the case you mentioned). The reason is that, for a closed form $\alpha$, the torus of periods $T_\alpha$, that is, quotient of $\bf R$ by the group of periods $P_\alpha$, is a manifold only when $P_\alpha = a {\bf Z}$, $a \in {\bf R}$. In other words, the manifold framework authorize you to represent only integral cohomology. That difficulty can be resolved by working in the category of diffeological spaces, because $T_\alpha$ is legit in this category. You can show that:


*

*Form any closed 1-form $\alpha$ on a diffeological space $X$, if the group of periods 
$$
P_\alpha = \left\{\int_\ell \alpha \ \left\vert\right. \ \ell \in {\rm Loops}(X)\right\}
$$
is diffeologically discrete, that is in this case, a strict subgroup of $\bf R$ (what always happen for second-countable manifolds) then there exists a smooth map $f : X \to T_\alpha = {\bf R}/P_\alpha$ such that $f^*(\theta) = \alpha$, where $\theta$ is the canonical 1-form on $T_\alpha$. 

*For a closed 2-form $\omega$ on X, what we can do is the following. Assume first that $X$ is simply connected. Let $\alpha = K\omega$, where $K$ is the chain-homotopy operator(${}^1$), $K\omega$ is a 1-form on ${\rm Paths}(X)$. Restricted to ${\rm Loops}(X)$, $K\omega$ is closed. The group of periods of $\omega$ is defined as the group of periods of $\alpha \restriction {\rm Loops}(X)$, that is,
$$
P_\omega = \left\{\int_\ell K\omega \ \left\vert\right. \ \ell \in {\rm Loops}({\rm Paths}(X))\right\}.
$$
Now, if $P_\omega$ is diffeologically discrete then there exists a principal $T_\omega$ fiber bundle over $X$ with a connexion $\lambda$ of curvature $\omega$. You can say that this is the smooth  geometric representation of $\omega$ you look for. As above, the condition of discretion is satisfied by any second-countable manifold. This construction is unique up to equivalence. If $X$ is not simply connected, these geometric representations (fiber bundles + connexion) are classified by $H^1(X,T_\omega)$. The principal bundles only are classified, up to equivalence, by ${\rm Ext}(\pi_1(X),P_\omega)$(${}^2$).
So, thanks to these two constructions you can represent smoothly any closed 1-forms or 2-forms on second countable manifolds whatever the group of period is, and any closed 1-forms or 2-forms on diffeological space with a diffeologically discrete group of periods. You can find the proofs of that in the paper La trilogie du moment (published in 1995), for the manifold case, and also in the book Diffeology, §8.42, published this year, for the general diffeological case.
Now, for higher degree, I must say that I have no satisfactory construction to propose. The fact is that if you look to represent a closed 3-form thanks to a structure bundle, it's a dead end because on $S^3$, every principal bundle with structure group a Lie-like group is trivial(${}^3$) (because $\pi_2(G)=0$). Personally, I'm not satisfied with what I read in the literature on the subject.
(1) Book Diffeology, §6.83.
(2) For a general diffeological space this is still a work in progress.
(3) Not true for a general diffeological group.
A: I think I understand the construction for $H^2(M)$ when $H_1(M, \mathbb{Z})=0$ and can make it more explicit than the other answers. As I noted in a comment above, when $H_1(M, \mathbb{Z})$ has torsion, we cannot hope for a canonical construction. When $H_1(M, \mathbb{Z})$ is torsion-free but nontrivial, there should be a construction, but I haven't found it. Also, I am terrible with functional analysis and infinite dimensional spaces so I will be vague about what "nice" means.
Let $\omega$ be a closed integral $2$-form on $M$. Let $\gamma$ be a closed path in $M$. Since $H_1(M)=0$, there is a surface $S$ with $\partial S = \gamma$. Define $\theta(\gamma) = \exp(2 \pi i \int_S \omega)$. We must check that this is independent of the choice of $S$: If $\partial S_1 = \partial S_2$ then $S_1 - S_2$ is a cycle in $H_2(M, \mathbb{Z})$ so $\int_{S_1-S_2} \omega \in \mathbb{Z}$ and we deduce that $\int_{S_1} \omega \equiv \int_{S_2} \omega \bmod \mathbb{Z}$.
Fix a base point $x_0$ in $M$. Let $T$ be the space of all nice paths in $M$ starting at $x_0$. If you fear infinite dimensional spaces more than you hate making choices, choose a metric on $M$, let $T$ be the tangent space to $M$ at $x_0$ and interpret "nice" as "geodesic"; by the Hopf-Rinow theorem, we can identify these with $M$. (I can't decide whether my hatred or my fear is greater.)
Let $V$ be the vector space of all nice functions $f:T \to \mathbb{C}$ with the property that, if $\gamma_1$ and $\gamma_2$ are two paths $x_0 \leadsto x_1$ then $f(\gamma_1) = \theta(\gamma_1-\gamma_2) f(\gamma_2)$. (If $T$ is the tangent space to $M$ at $x$, I think we can take "nice" to be "smooth".)
Any path $\gamma$ now gives a linear functional $V \to \mathbb{C}$ by $f \mapsto 
f(\gamma)$. If $\gamma_1$ and $\gamma_2$ both have endpoint $x_1$, then the corresponding linear functionals are proportional. So each $x \in M$ defines a point in $\mathbb{P}(V^{\ast})$. Up to the question of how to put a smooth structure on $\mathbb{P}(V^{\ast})$, we have embedded $M$ into an infinite dimensional projective space.
Again, if you fear infinite dimensional spaces more than you hate choices, rather than working with all of $V$, choose a finite dimensional subspace such that, for any $x \in M$, there is some $f \in V$ which is nonzero at $x$. We could try doing something like restricting ourselves to harmonic functions $f$ in the hope of getting a canonical finite dimensional subspace, but then we would get into the question of what the analogue of "ample" is in this setting. I don't know, but maybe some differential geometer does.

This was the result of composing two tricks. The second trick is familiar to algebraic geometers: If $L$ is a vector bundle on $X$ and $V$ is its space of global sections, then $X$ embeds, choice-free, into $\mathbb{P}(V^{\ast})$.
The first trick was that, given a line bundle $L$ with connection, I can think of sections of $L$ over $M$ as functions $T \to \mathbb{C}$ whose holonomy respects the holonomy of the connection. I then remembered enough about how curvature works to see that I could write down the holonomy without building the line bundle or the connection.
If $H_1(M)$ is nonzero, define $Z_1(M)$ to be the integer $1$-cycles and $B_1(M)$ the integer $1$-boundaries, so $H_1(M) = Z_1(M)/B_1(M)$. The map $\theta$ still makes sense as a map $B_1(M) \to U(1)$. I think what we are supposed to do is lift $\theta$ to a map $\tilde{\theta}: C_1(M) \to U(1)$. Once we have done that, there is no problem with repeating the above construction with $\tilde{\theta}$. Presumably, there is a theorem that it only matters what choice we make on torsion elements of $C_1(M)/B_1(M)$, but that isn't clear to me.
